Search

Hi all,

I'm trying to work out the best way to approach a complex form, I have a feeling I'll need a custom event (which intimidates me) but thought I'd see if others have had to solve this issue themselves, and how they might have done it.

The problem:

I have 3-layer one-to-many data relationship - an example might be:

Contact

  • Name
  • Email
  • Reference

Claim

  • Type
  • Date submitted
  • Reference
  • SBL -> Contact[Reference]

Item

  • Title
  • Description
  • Reference
  • SBL -> Claim[Reference]

So a single contact can have many claims, and a claim can have many items.

The problem is that this information is all provided in a single form, on one page. So I need to fire an event for each section of the form, whilst also passing the reference on to the next. i.e. the Contact event is fired, and the reference is created, and then passed onto the Claim event, which fires, and the reference from the claim is then passed on to the item event and that's fired (and there could be any number of 'items' in the same form, so the event would need to fire for each).

Separating the form into multiple pages would be a big negative in this case, a barrier that would likely effect conversion - so although it's the easiest solution it's one I wish to avoid.

Looking forward to hearing your thoughts!

Here you go... https://gist.github.com/brendo/901476

Previous ramblings here and here! ;)

Ah, looks perfect, thanks Jens!!

I'll be back when I inevitably break something :)

When you are brave enough and have a thirst to delve deeper.. It may help to take a look at Sections Event extension.

It has a custom event which gathers all data from all submitted data and section info and processes it only if all criteria for all sections is met. Pretty sweet. We have it working well with section schemas as well for really speedy form building based on section structure in the backend.

That does look interesting Andrew, thanks - haven't come across that extension before!

Having issues with scope and the ROOTELEMENT constant/variable

Edit: Actually I think this is just part of the variable issue - it's retuning NULL - scope issue. I've done some fiddling but am hitting this issue:

http://www.getsymphony.com/discuss/thread/105990/

I'm changing it to a constant but I assume this was changed for a reason - any thoughts?

Minor issue following the tutorial, I'm hoping someone can help!

This relates specifically to this section of the tut.

I don't seem to be able to name the hidden id field anything but 'id', as I'm guessing that's an integral part of the 'update' logic (looking for a field named id).

So the following happens:

  1. Input valid data in create-car fields, invalid data in create-dealer fields
  2. System creates the entry for create-car, the ID of which is now included in the markup so it will update not recreate it. create-dealer reports correctly as 'error'.
  3. Correct all fields, re-submit.
  4. create-car successfully reports as 'updated', however create-dealer also reports as 'success' and 'updated', although this should be 'created', and more importantly in this case isn't created anyway, so the response is entirely false. By all rights it should be reporting 'error', as nothing ends up in the backend.

I'm assuming this is something to with the ambiguous 'id' field - confusing Symphony. As it thinks it's updated the second event.

Am I missing something?

I managed to resolve the previous issue by unsetting the id before the second event fires, so create-dealer looks more like:

protected function __trigger()
    {
        unset($_POST['id']);

        unset($_POST['fields']);
        $_POST['fields'] = $this->post[self::ROOTELEMENT]['fields'];

        include(TOOLKIT . '/events/event.section.php');

        return $result;
    }

All works as intended now!

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details