Search

Hi folks, was hoping somebody could help,

I currently have a form that on submission will create an entry in a section. (that's the normal part)

Within the event that is being used for that I also have another event submitting automatically like this:

$_POST['action']['event-name'] = 'Submit';

Now the problem lies within the second event that is being automatically fired, what I'm trying to do is have that event populate a field within an existing entry but for a different section, the ID for this entry is obtained within the first event.

Using the code below I'm currently having a little bit of success as the entry is being updated however it seems to be removing some of the data within the other fields automatically.

Just to note, 'new-registrations' is the name of the first event that the form is submitting and 'discounts-used' is the name of the event that is being fired off from within 'new-registrations'.

<?php
    require_once(TOOLKIT . '/class.event.php');

    Class eventdiscounts_used extends SectionEvent{

        const ROOTELEMENT = 'discounts-used';

        public $eParamFILTERS = array(

        );

        public static function about(){
            return array(
                'name' => 'Discounts Used',
                'author' => array(
                    'name' => 'John Doe',
                    'website' => 'https://johndoe.com',
                    'email' => 'john@doe.com'),
                'version' => 'Symphony 2.3.3',
                'release-date' => '2015-08-05T16:19:07+00:00',
                'trigger-condition' => 'action[discounts-used]'
            );
        }

        public static function getSource(){
            return '14';
        }

        public static function allowEditorToParse(){
            return false;
        }

        public static function documentation(){
        }

        public function load(){
            $this->post = $_POST;
            if(isset($_POST['action']['discounts-used'])) return $this->__trigger();
        }

        protected function __trigger(){

              $discount = $this->post['new-registrations']['fields']['discount-code'];

              $_POST['id'] = $discount;
              $_POST['fields']['used'] = 'Yes';

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



    }

Can anybody shed any light on this?

Many thanks.

Symphony shouldn't update fields which are not in the $_POST array. Maybe the fields have the same name in both sections? In this case I would assume that these fields are still existing in the $_POST array, and you should be able to solve it by unsetting the $_POST array first, before adding the id and the used field.

Brill thanks Michael, that did the trick.

It was just a shot in the dark — great to hear that I hit the bull's eye! :-)

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