/**
  * Adds standard data to the element.
  * @param \SimpleXMLElement The xml element to expand, by reference
  */
 protected function addFields(\SimpleXMLElement $xml)
 {
     $xml->tabindex = $this->tabindex;
     parent::addFields($xml);
 }
Exemple #2
0
 /**
  * Generates the XML child in the given XML root.
  * This function should be implemented by every FormElement.
  * @param \SimpleXMLElement The XML node to add the current element to.
  * @return \SimpleXMLElement The newly created node
  */
 public function generateXML(\SimpleXMLElement $xml)
 {
     $form = $xml->addChild('form');
     $form->action = $this->action;
     $form->accept = $this->accept;
     $form->acceptcharset = $this->acceptCharset;
     $form->enctype = $this->encType;
     $form->method = $this->method;
     $form->target = $this->target;
     //this needs a different setting
     if (!$this->autoComplete) {
         $form->autocomplete = 'off';
     }
     if ($this->noValidate) {
         $form->novalidate = 'on';
     }
     $form->events->onreset = $this->onReset;
     $form->events->onsubmit = $this->onSubmit;
     $elements = $form->addChild('formelements');
     if ($this->getAddTokenField()) {
         //add the formtoken element as a regular input type="hidden" element
         $hidden = new \Module\HTMLForm\Element\InputHidden(self::FORMTOKEN_FIELDNAME, self::getFormToken($this->id));
         $this->addElement($hidden);
     }
     $initContent = '';
     foreach ($this->elements as $element) {
         $element->generateXML($elements);
         $initContent .= $element->getOnInit();
     }
     //add the initcontent to the xml, so all elements get initialized upon form display
     $form->init = $initContent;
     parent::addFields($form);
     return $form;
 }