Exemplo n.º 1
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.
  */
 protected function addFields(\SimpleXMLElement $xml)
 {
     parent::addFields($xml);
     $xml->disabled = $this->disabled;
     $xml->name = $this->name;
     $xml->value = $this->value;
     $xml->events->onblur = $this->onBlur;
     $xml->events->onfocus = $this->onFocus;
 }
Exemplo n.º 2
0
 /**
  * Outputs the initialization script for the validation and replaces the predefined js template stuff for the actual fieldnames and values.
  * @param \Module\HTMLForm\HTMLInputFormElement The element to apply onInit to.
  * @param string The script to apply. This is the sum of all the functions.
  * @param array An array containing all the function calls.
  * @param string The events to bind to.
  */
 public static final function prepareValidationJS(\Module\HTMLForm\HTMLInputFormElement $element, $validationScript, array $functionCalls, $events)
 {
     $validationScript = '
         $(function() {
             $("#{ID}").on("' . $events . '", function() {
                 if ({FUNCTIONS}) {
                     $(this).removeClass("error notice");
                 }
                 else {
                     $(this).addClass("error");
                 }
             });
         });' . $validationScript;
     $validationScript = str_ireplace('{FUNCTIONS}', implode('&&', $functionCalls), $validationScript);
     $validationScript = str_ireplace('{ID}', $element->getId(), $validationScript);
     return $validationScript;
 }
Exemplo n.º 3
0
 /**
  * Adds standard data to the element.
  * @param \SimpleXMLElement The xml element to expand, by reference
  */
 protected function addFields(\SimpleXMLElement $xml)
 {
     parent::addFields($xml);
     $xml->disabled = $this->disabled;
     $xml->name = $this->name;
     $xml->size = $this->size;
     $xml->value = $this->value;
     $xml->form = $this->form;
     if ($this->autoFocus) {
         $xml->autofocus = 'on';
     }
     $xml->events->onblur = $this->onBlur;
     $xml->events->onchange = $this->onChange;
     $xml->events->onfocus = $this->onFocus;
     $xml->events->onselect = $this->onSelect;
 }