/**
  * Create a new instance of a form page.
  * 
  * This will call the constructor for all Page objects and then set up some additional
  * member variables for forms.
  * @param string $title The title for this page.
  * @param string $defaultHTMLFile The default HTML file for this page.
  * @param mixed $access The role required to access this page.
  * @param array $files The list of template files to load for this page.
  */
 public function __construct($args, $request_remainder, $get = null, $post = null)
 {
     parent::__construct($args, $request_remainder, $get, $post);
     $this->editing = false;
     $this->factory = I2CE_FormFactory::instance();
     $this->invalid = false;
     $this->files = array();
     $this->current = array();
     $this->cache = array();
     // Default to not using a confirm page for this type of page.
     // If an arg exists, it will be set from the parent class
     if (!array_key_exists('confirm', $args)) {
         $this->usesConfirmPage = false;
     }
 }
 /**
  * Add the form_error template to the page if the template is marked as invalid.
  */
 public function invalidMessage()
 {
     $node = parent::invalidMessage();
     if ($node instanceof DOMNode) {
         foreach (array(self::EDIT_PARENT, self::EDIT_PRIMARY) as $key) {
             if (!$this->objects[$key] instanceof I2CE_Form) {
                 continue;
             }
             if ($this->objects[$key]->hasInvalid()) {
                 foreach ($this->objects[$key] as $field) {
                     if (!$field instanceof I2CE_FormField) {
                         continue;
                     }
                     if ($field->hasInvalid()) {
                         $node->appendChild($this->template->createElement('span', array('style' => 'display:none'), $field->getHTMLName()));
                     }
                 }
             }
         }
         foreach (array(self::EDIT_SECONDARY, self::EDIT_CHILD) as $key) {
             if (!is_array($this->objects[$key])) {
                 continue;
             }
             foreach ($this->objects[$key] as $form) {
                 if (!$form instanceof I2CE_Form) {
                     continue;
                 }
                 if ($form->hasInvalid()) {
                     foreach ($form as $field) {
                         if (!$field instanceof I2CE_FormField) {
                             continue;
                         }
                         if ($field->hasInvalid()) {
                             $node->appendChild($this->template->createElement('span', array('style' => 'display:none'), $field->getHTMLName()));
                         }
                     }
                 }
             }
         }
     }
     return $node;
 }
 /**
  * Load the  template (HTML or XML) files to the template object.
  *  
  * 
  */
 protected function loadHTMLTemplates()
 {
     parent::loadHTMLTemplates();
     $this->setDisplayData('parent', $this->request('parent'));
     $first = true;
     foreach ($this->existing_objects as $id => $obj) {
         $this->addExistingTemplate($id);
     }
     if (count($this->existing_objects) > 0) {
         $this->template->setDisplayData('has_existing', 1);
     } else {
         $this->template->setDisplayData('has_existing', 0);
     }
     foreach ($this->objects as $obj) {
         $this->addAnonymousTemplate($first);
         $first = false;
     }
 }