Search

Yes, it is possible. Look at the event tutorial which @brendo has started to write!

Can anyone think of an approach where I would be able to submit to a second entry only if a specific option in a select box was checked? and if not don't submit an entry to that section, but still submit to the main section? klaftertief's approach is simple and wondering if there's a case for logic (choose/otherwise) kind of apporach if option is true..

Getting into EventEx but struggling to see where I'd be able to negate the posting of entry to additional sections under certain circumstances.

does anyone see any issues with this approach?

Did you read that tutorial? There's a section that almost describes exactly that scenario, it should put you in the right direction

I'm there :) The case I am after is populating a select box with a field value if the "Client Name" is already in the section, but If I need to add a New client name into the section called "clients", I need to have the select box submit nothing, but a new series of input fields populate the "Clients" section with a new client and Take the "client name" to populate the select box of the Master Section.... wheeew...

Struggling to see where the EventEx logic can submit to 2 sections from one input field and also populate the selectbox with an entry that hasn't been created in the "Clients" section yet.

Will read through and see if something sticks :)

I need a little help learning to chain events, please:

EDIT: (see bottom of post)

I am chaining two events (updating two sections) and the set-up is as follows:

  • The first event is triggered on form submit, and if successful, the second one must be triggered.
  • The first event creates a new entry, the second event updates an existing entry.
  • Through a hidden field in the form I am passing the id of the entry that needs to be updated by the second event.

My questions:

  1. I am using the standard names in the form fields (fields[field-name], instead of event-handle[fields][field-name]), because the action for the second event is triggered from the trigger function of the first event, only if successful, and the second event is custom, so there shouldn't be a risk of saving the entries to the wrong section, even if a field name could be the same in both sections. Is this correct?

  2. The second event uses two values from the form. To get them, should I first post all inputs in the event's load function ($this->post = $_POST;), and then in the trigger function, put the needed values into variables ($variablename = $POST['field-name'];)?

  3. As mentioned above, through the form I am passing the id of the entry that needs to be updated by the second event. The form field's name is row-id, instead of id to avoid updating an existing entry with the fisrt event. How would I get its value in the second event's trigger function? Should it be something like

$entry_id = if (isset($_POST['row-id']) && is_numeric($_POST['row-id'])) $_POST['id'] = $_POST['row-id'] : null;?

  1. It's possible to update only certain fields with the second event, correct? The values for other fields won't be reset? Or I have to set values for all fields in an entry?

I understand that these are rather generic beginner questions, but I can't get any PHP down, before clearing the concepts. Thanks a lot for your help!

EDIT: This is incredible, I don't know PHP and I just managed to chain the events, even write custom trigger ! I love Symphony! Thank you for supporting this beautiful CMS!

Hi Guys, I get this submitting multiple forms thing and it works pretty good. I have one instance that I cannot figure out and any help would be appreciated.

I have 2 sections that are connected with the bi-link field extension. I was wondering if it is possible to submit to 2 forms and also create this relationship in the process. The current method creates two seperate records which have to be linked manually.

Thanks

EDIT:

Perhaps I am making this more complicated than neccessary - what is the best way to set up sections with many to many relationships that could be managed from the front - should I just chain events and use id fields?

@Ellie you've just helped me figure out a select box link solution for my multiple entry posting.. thanks :) for posting your solution!

@callumrexter does the bi-link field use ID's to reference other sections?

Yes it does.

Hmmm. Any idea how I would catch the ID of a chained event into the load function?

I have a chained event that I want triggered before the main event to capture it's ID.

Here's what I have:

public function load(){


                    if(!empty($_POST['new-client']['fields']['client-name'])) {$_POST['job-enquiry']['fields']['client'] = $_POST['new-client']['id'];}else{}
                    if(!empty($_POST['new-venue']['fields']['venue-name'])) {$_POST['job-enquiry']['fields']['venue'] = $_POST['new-venue']['id'];}else{}
                    $this->post = $_POST;
                    if(isset($_POST['action'][self::ROOTELEMENT])) return $this->__trigger();

        }

        protected function __trigger(){

                    //var_dump($_POST);

            unset($_POST['fields']);

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

            if($_POST['new-client']['fields']['client-name'] != ""){$_POST['action']['new-client'] = 'Submit';}
                    if($_POST['new-venue']['fields']['venue-name'] != ""){$_POST['action']['new-venue'] = 'Submit';}
                    include(TOOLKIT . '/events/event.section.php');

                    return $result;
        }

I did a VAR dump but I see no Post ID in the array: I'm guessing I wouldn't see it yet cos it's not fired, so how would I target the event/new-client/@id in the event.php file?

The reason for wanting the Post ID for each event is cos I have Select Box Link fields for Venue and Client and I can't think of how to retrieve the POST ID from the resulting event submission and place it in the load function above.

Here my whole event file: event.job-enquiry.php

Thanks for the great tutorial, how would I go about redirecting to another page after the second Event Successfully executes?

Can i combine some of those concepts with Form Controls xslt utility?

Form Controls does in fact support posting to multiple sections, but it is heavily tied to EventEx (a somewhat archaic way of posting to multiple extensions). Adding support isn't impossible, but I'd like one day to rewrite it with this in mind!

@nick,

is there a way to implement "trigger second only if first succeed" workflow with EventEx?

@ixi, Brendo's tutorial walks through this exact scenario.

Read down to the Title "I only want 'y' to execute if 'x' was successful!" in the tut.

@moonoo2 yes, indeed. can't decide which way to go.

EventEx works fine (symphony 2.2.1) and it's integrated with Form Controls. maybe it worth efforts to continue development of the plugin? it lacks feature i mentioned and of course back-end is absence.

however i'm not a php expert and source code of EventEx scared me a bit :)

EDIT

brendo's tutorial is excellent, everything worked like a charm. i was also able to make my events play nicely with Form Controls using EventEx notation, which is event-name[field-name] instead of event-name[fields][field-name]

by changing

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

to

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

Do you think anything's wrong with the below code? I had it working on another installation (2.2, using @brendo's tutorial) but it keeps throwing errors in 2.3.1. It is supposed to trigger a second event if successful.

public function load(){
    if(isset($_POST['action'][self::ROOTELEMENT])) return $this->__trigger();
}
protected function __trigger(){
    if($result->getAttribute('result') == "success") {
        $_POST['action']['update-story'] = 'Submit';
    }
    return $result;
}

The error I get (on load) is: Fatal error: Undefined class constant 'ROOTELEMENT'. And if I hard code the event's name the error follows me forward (on trigger), becoming Fatal error: Call to a member function getAttribute() on a non-object. (And even if I remove the condition it follows me to the next event, but this deserves another post...)

Without chaining, the event executes without errors. Has anyone made chained events in 2.3? I appreciate your help!

Like ellie, I too would appreciate some guidance regarding chaining events in 2.3 too. I get the same ROOTELEMENT errors.

Could Brendos explanation to Jens question be the answer? https://gist.github.com/901476#comment-363005

Correct, that article was written a long time ago, and it was never published because I never considered the tutorial easy enough to follow. Obviously quite a few have managed to understand it though!

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