Search

Is it possible to alter the $_POST values of entry fields in an event?

I'm trying to alter an Event $_POST value if the option select value is "0".

Been reading Brendo's tutorial, but not that hot on PHP functions.. could anyone help with a little php that would go in the event php file to change the value of $_POST['job-enquiry']['fields']['client'] from "0" to another fields submitted value?

$_POST['job-enquiry']['fields']['client'] = $_POST['your-other-field'];

Hi Brendo, I had been using this approach anyways but did'nt have any luck.

I'm guessing that the alteration should happen in the trigger function no? As that's where the values get sent to the sections? What I'm encountering is the value of "0" is being entered into the section field no matter what conditions I place on PHP. i.e:

if($_POST['job-enquiry']['field']['client'] == "0"){$_POST['job-enquiry']['field']['client'] = $_POST['new-client']['field']['client-name'];}

Any idea why this would not alter the field value?

P.S applogies for jumping threads.

Have you tried a 0 without " around it?

I had a similar question recently about $_GET values and it works fine...

Tried that, I think it's something to do with the order the events get triggered, meaning the chained event is posted after the primary event meaning I can't influence the post values. Is there a means to influence the priority of the chained event to override the primary event from within the primary events php? wheew ya know what I mean? I know Brendo's tutorial indicated it was possible to prioritise using kHIGH etc but that was to prioritise the current event not the chained event?

Because the select option value of the [job-enquiry][fields][client] is 0 it does not get submitted.. if I change it to 1 in the Page XML, I see the post values for <client>1</client>, which is a start.. but I can't influence/change that value using the code below:

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

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

                        if($_POST['job-enquiry']['fields']['client'] == "1"){
$_POST['action']['new-client'] = 'Submit';
$_POST['job-enquiry']['fields']['client'] = $_POST['new-client']['fields']['client-name'];

                       }
                        return $result;
        }

Any help here would be greatly appreciated.

Can you post a var_dump($_POST) just after the start of the trigger function?

I have a feeling this is because the $this->post is set on the load of the Event (ie. as soon as the page is loaded), so changing $_POST values doesn't have any effect because the trigger function of your chained event will use $this->post, which was set before you changed the value.

In the chained event, you explicitly can set $_POST['fields'] as normal by referencing $this->post and then after that set $_POST['fields']['field'] = $_POST['go']['to-your-field-set-in-the-previous-event-condition']`

This what your after?

array(4) { ["job-enquiry"]=> array(2) { ["fields"]=> array(14) { ["submitted-by"]=> string(13) "Username" ["client"]=> string(10) "New Client" ["department"]=> string(7) "General" ["number-of-deligates"]=> string(0) "" ["layout"]=> string(0) "" ["production-type"]=> string(1) "0" ["artist"]=> string(0) "" ["type-of-media"]=> string(0) "" ["location"]=> string(0) "" ["date-of-event"]=> string(0) "" ["venue"]=> string(0) "" ["budget"]=> string(2) "78" ["notes"]=> string(5) "asfas" ["date-of-enquiry"]=> string(10) "2011-06-07" } ["graphic-design-website"]=> string(1) "0" } ["new-client"]=> array(1) { ["fields"]=> array(8) { ["client-name"]=> string(3) "App" ["client-contact-name"]=> string(0) "" ["contact-email-address"]=> string(0) "" ["client-address"]=> string(0) "" ["postcode"]=> string(0) "" ["tel"]=> string(0) "" ["website"]=> string(0) "" ["referal"]=> string(0) "" } } ["venues"]=> array(1) { ["fields"]=> array(2) { ["venue-name"]=> string(0) "" ["venue-capacity"]=> string(0) "" } } ["action"]=> array(1) { ["job-enquiry"]=> string(6) "Submit" } }

Is there a way to influence the chained datasource to trigger before the primary datasource at all?

I can see the chained one takes values from the primary one.. but I need it the other way round..

EDIT

Orrrr within my Primary event trigger, send an edited rather than new entry back into Job-Enquiry section with reference to the new-client field from the New Client chained event?

How would I achieve this by placing the ID of the current 'job-enquiry' entry into the if statement?

EDIT 2 :)

Has anybody ever used an event without an attached section to control the posting of submit actions to desired sections? I'm in need of a master even that can conditionally post to sections if certain fields are not empty.

I'll extend my tutorial in the coming days to include this

Ahhhh you star :) Really love Symphony and am learning 100 fold each day, but when it comes to altering functions, I'm not sure where to start.. some of this is not covered in the API.. with regards to load() and __trigger.. where's best to read up on what can and can't be included in these fucntions? as your post above explains why I am not able to influence the posted data.. looking into JS onchange approaches to the fields entry for now.. not the best, but it's a short term solution :)

Hey Brendo, I think i've got something working for my needs by placing this code in the load function: `public function load(){

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

        }

`

Being as I need to check the values of the Post array before triggering the Event, This is what I was after.. Do you see any issues doing it this way?

EDIT

Spoke too soon! it appears in the vardump to be what I wanted.. but when I comment out vardump and post event.. the value didn't change.. hmmmmm To the Drawing board with thee!

EDIT2

If I place $this->post = $_POST; after my if conditional statement.. fingers crossed all is well :)

Just realised the above approach would not work if I was using a "Select Box Link Field" cos the New Client field value is a Text String at present(whichi is fine and working).. but If I wanted it to be dynamic and use Select Box Linkage on the section, I'd need the New Client Entry ID from the post-values... but my event triggers in the wrong order so defo need an Event to control conditional triggering of all event's.. look forward to a little insight when you get a chance Brendo.

Any way to target a chained event POST ID inside the load event? is it too early in the process?

I'm able to alter POST values based on if fields are not empty in the load function, but I have a case where the chained event is fired after my master event and I can't seem to figure out what to use to target the chained event $_POST['id'] value in the event php.

Here's what I have in my load function:

public function load(){


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

        }

I'm trying to get the chained events event/new-client/@id and events/new-venue/@id to be able to post these values into the post array when it fires.. The above fields are expecting integers, due to there being Select Box links in use on the master section fields.

Any pointers/direction as to where it's going wrong would be greatly appreciated.

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