/**
  * Create and load any necessary objects for this form.
  */
 protected function loadObjects()
 {
     if ($this->id != '0') {
         $obj = $this->factory->createContainer($this->id);
     } else {
         $obj = $this->factory->createContainer("training_program");
     }
     if ($this->get_exists('training_institution')) {
         $obj->getField("training_institution")->setFromDB($this->get('training_institution'));
     }
     $this->setObject($obj);
     parent::loadObjects();
 }
 /**
  * Create and load data for the objects used for this form.
  * 
  * Create the list object and if this is a form submission load
  * the data from the form data.  It determines the type based on the
  * {@link $type} member variable.
  */
 protected function loadObjects()
 {
     if (!$this->isPost() && (strlen($this->id) == 0 || $this->id == $this->type . '|0') && (!$this->get_exists('add') && !$this->type)) {
         return true;
     }
     //we want to load objects for a GET request when the id was not been explicitly set and it is not an add
     // if ( $this->isPost()
     //      ||  (!( strlen($this->id ) == 0   || ($this->id == $this->type . '|0') ))
     //      || !$this->get_exists('add') ) {
     //     //we don't need to load objects
     //     return true;
     // }
     if (!$this->type) {
         return !$this->isPost();
     }
     $factory = I2CE_FormFactory::instance();
     if ($this->id) {
         $obj = $factory->createContainer($this->id);
     } else {
         $obj = $factory->createContainer($this->type);
     }
     if (!$obj instanceof I2CE_List) {
         I2CE::raiseError("Trying to edit {$this->type}|{$this->id} which is not a list:" . get_class($obj));
         return false;
     }
     $this->setObject($obj);
     if ($this->isConfirm(false) || $obj->getId() != '0') {
         $this->template->setForm($obj);
         //make sure this is the default object for the page
     }
     if ($this->select_field) {
         $this->select_field = $obj->getField($this->select_field);
         $obj->load($this->request(), false, false);
         if ($this->select_field instanceof I2CE_FormField_MAP) {
             $selectObj = $this->select_field->getMappedFormObject();
             if ($selectObj instanceof I2CE_Form) {
                 //make this object avaialable for record level security
                 $this->template->setForm($selectObj);
             }
         }
     }
     $child_forms = $obj->getChildForms();
     foreach ($child_forms as $i => $child_form) {
         $template_file = $this->getChildHTMLTemplate($child_form);
         $template_file = $this->template->findTemplate($template_file, false);
         if ($template_file) {
             continue;
         }
         unset($child_forms[$i]);
     }
     if ($obj->getId() == '0') {
         foreach ($child_forms as $child_form) {
             $childObj = $factory->createContainer($child_form);
             if (!$childObj instanceof I2CE_Form) {
                 I2CE::raiseError("Could not create the  form " . $child_form);
                 continue;
             }
             $obj->addChildForm($childObj);
             $this->setObject($childObj, I2CE_PageForm::EDIT_CHILD);
         }
     } else {
         foreach ($child_forms as $child_form) {
             $obj->populateChild($child_form);
             $childObjs = $obj->getChildren($child_form);
             if (count($childObjs) == 0) {
                 //create the child form as it does not exist
                 $childObj = $factory->createContainer($child_form);
                 if (!$childObj instanceof I2CE_Form) {
                     I2CE::raiseError("Could not create the  form " . $child_form);
                     continue;
                 }
                 $obj->addChildForm($childObj);
                 $this->setObject($childObj, I2CE_PageForm::EDIT_CHILD);
             } else {
                 foreach ($childObjs as $childObj) {
                     $this->setObject($childObj, I2CE_PageForm::EDIT_CHILD, $childObj->getNameId());
                 }
             }
         }
     }
     return parent::loadObjects();
 }
 /**
  * Create and load data for the objects used for this form.
  */
 protected function loadObjects()
 {
     $loaded = false;
     if ($this->isPost()) {
         $obj = $this->factory->createContainer("training_disrupt");
         $obj->load($this->post);
         $this->parent_id = $obj->getParent();
     }
     $parent = $this->factory->createContainer($this->parent_id);
     $parent->populate();
     $parent->populateChildren("training_disrupt");
     foreach ($parent->children as $form => $list) {
         if ($form != "training_disrupt") {
             continue;
         }
         foreach ($list as $obj) {
             if (!I2CE_Validate::checkDate($obj->resumption_date)) {
                 $this->id = $obj->getId();
                 $this->setObject($obj);
                 $this->setObject($parent, I2CE_PageForm::EDIT_PARENT);
                 $loaded = true;
                 break;
             }
         }
     }
     I2CE_PageForm::loadObjects();
     if (!$loaded) {
         $this->setRedirect("view_training?id=" . $parent->getId());
     }
 }
 /**
  * Create and load data for the objects used for this form.
  */
 protected function loadObjects()
 {
     $loaded = false;
     if ($this->isPost()) {
         $obj = $this->factory->createContainer("disciplinary_action");
         $obj->load($this->post);
         $this->parent_id = $obj->getParent();
     }
     $parent = $this->factory->createContainer($this->parent_id);
     $parent->populate();
     $parent->populateChildren("disciplinary_action");
     foreach ($parent->children as $form => $list) {
         if ($form != "disciplinary_action") {
             continue;
         }
         foreach ($list as $obj) {
             if ($obj->suspend) {
                 $this->id = $obj->getId();
                 $this->setObject($obj);
                 $this->setObject($parent, I2CE_PageForm::EDIT_PARENT);
                 $loaded = true;
                 break;
             }
         }
     }
     I2CE_PageForm::loadObjects();
     if ($loaded && !$this->isPost()) {
         $this->getPrimary()->reinstate_date = I2CE_Date::now();
     }
     if (!$loaded) {
         $this->setRedirect("view_training?id=" . $parent->getId());
     }
     /*
             if ( $this->factory->exists( $this->getForm() ) )
                     $this->setObject( $this->factory->createContainer( $this->getForm().'|'. $this->id ) );
             $parent = $this->factory->createContainer( "training".'|'. $this->parent_id );
             $parent->populate();
             $this->setObject( $parent, PageForm::EDIT_PARENT );
             parent::loadObjects();
     */
 }
 /**
  * Create and load data for the objects used for this form.
  */
 protected function loadObjects()
 {
     if ($this->factory->exists($this->getForm())) {
         $this->setObject($this->factory->createContainer($this->getForm() . '|' . $this->id));
         if ($this->isPost()) {
             $this->getPrimary()->load($this->post);
             $this->parent_id = $this->getPrimary()->getParent();
         }
     }
     if ($this->parent_id != '' && $this->getForm() != "training") {
         $parent = $this->factory->createContainer($this->parent_id);
         $parent->populate();
         $this->setObject($parent, I2CE_PageForm::EDIT_PARENT);
     }
     parent::loadObjects();
     /*
             $this->edit_obj->setParent( $this->parent->getId() );
             if ( $this->isPost() ) {
                     $this->edit_obj->load( $_POST );
             } elseif ( $this->edit_obj->getId() > 0 ) {
                     $this->edit_obj->populate();
                     $this->setEditing();
             }
     */
 }
 /**
  * Create and load data for the objects used for this form.
  * 
  * Create the list object and if this is a form submission load
  * the data from the form data.  It determines the type based on the
  * {@link $type} member variable.
  */
 protected function loadObjects()
 {
     if ($this->factory->exists($this->getForm())) {
         $this->setObject($this->factory->createContainer($this->getForm() . '|' . $this->id));
         if ($this->isPost()) {
             $this->getPrimary()->load($this->post);
             $this->parent_id = $this->getPrimary()->getParent();
         }
     }
     if ($this->parent_id != '' && $this->getForm() != "training_institution") {
         $parent = $this->factory->createContainer($this->parent_id);
         $parent->populate();
         $this->setObject($parent, I2CE_PageForm::EDIT_PARENT);
     }
     parent::loadObjects();
 }
 /**
  * Create and load data for the objects used for this form.
  */
 protected function loadObjects()
 {
     if ($this->factory->exists('person_exam')) {
         if ($this->id) {
             $this->setObject($this->factory->createContainer($this->id));
         } else {
             $this->setObject($this->factory->createContainer('person_exam'));
         }
         if ($this->isPost()) {
             $this->getPrimary()->load($this->post);
             $this->parent_id = $this->getPrimary()->getParent();
         }
     }
     if ($this->parent_id != '') {
         $parent = $this->factory->createContainer($this->parent_id);
         $parent->populate();
         $this->setObject($parent, I2CE_PageForm::EDIT_PARENT);
     }
     parent::loadObjects();
 }
 /**
  * Create and load data for the objects used for this form.
  * 
  * Create the list object and if this is a form submission load
  * the data from the form data.
  */
 protected function loadObjects()
 {
     if (!$this->permissionParser->hasTask('person_can_edit_child_form_person_scheduled_training_course')) {
         $this->userMessage("You do not have permission to add or edit a person's scheduleing of training course", 'notice', true);
         $this->setRedirect('noaccess');
         return false;
     }
     $factory = I2CE_FormFactory::instance();
     $personScheduledCourse = $factory->createContainer($this->id);
     if (!$personScheduledCourse instanceof I2CE_Form) {
         return false;
     }
     $this->setObject($personScheduledCourse);
     if ($personScheduledCourse->getId() != '0') {
         $personScheduledCourse->populate();
         $this->person_id = $personScheduledCourse->getParent();
         if ($personScheduledCourse->getField('request_date')->issetValue()) {
             $personScheduledCourse->request_date = I2CE_Date::now();
         }
     }
     if ($this->person_id === false) {
         return false;
     }
     $parent = $factory->createContainer($this->person_id);
     if ($parent instanceof I2CE_Form) {
         $parent->populate();
         $this->setObject($parent, I2CE_PageForm::EDIT_PARENT);
     }
     parent::loadObjects();
 }