Skip to content

Instantly share code, notes, and snippets.

@johnpuddephatt
Created January 29, 2016 12:37
Show Gist options
  • Save johnpuddephatt/45d42e30865a7061c9c8 to your computer and use it in GitHub Desktop.
Save johnpuddephatt/45d42e30865a7061c9c8 to your computer and use it in GitHub Desktop.
<?php
require_once(TOOLKIT . '/class.event.php');
class eventcreate_child extends SectionEvent
{
public $ROOTELEMENT = 'create-child';
public $eParamFILTERS = array();
public static function about()
{
return array(
'name' => 'Create child',
'author' => array(
'name' => 'john puddephatt',
'website' => '###',
'email' => '###'),
'version' => 'Symphony 2.6.5',
'release-date' => '2016-01-29T10:18:14+00:00',
'trigger-condition' => 'action[create-child]'
);
}
public function priority(){
return self::kHIGH;
}
public static function getSource()
{
return '1';
}
public static function allowEditorToParse()
{
return false;
}
public static function documentation()
{
return 'Chaining...'
}
public function load()
{
$this->post = $_POST;
if (isset($_POST['action']['create-child'])) {
unset($_POST['fields']);
$_POST['fields'] = $this->post['create-child']['fields'];
$result = $this->__trigger();
if($result->getAttribute('result') == "success") {
unset($_POST['action']['create-child']);
unset($_POST['fields']);
$_POST['fields'] = $this->post['create-parent']['fields'];
$child_id = $result->getAttribute('id');
$_POST['fields']['children']['entries'] = [$child_id];
$_POST['action']['create-parent'] = 'Submit';
}
return $result;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment