/**
  * Adds a new component to the element list
  *
  * @param string $component_name
  * @param IFormComponent $component
  * @return IFormComponent
  */
 final function set($component, $component_name, $html_name = null)
 {
     if (isset($this->_elements[$component_name])) {
         trigger_error("There is already a form element with the name '{$component_name}'", E_USER_WARNING);
     }
     $component->setName($component_name, $html_name);
     if (isset($this->_raw_value[$component_name])) {
         // Value was sent
         $component->setRawValue($this->_raw_value[$component_name]);
     } else {
         if ($this->_raw_value) {
             // Put null value if sent but not present
             $component->setRawValue(null);
         }
     }
     if (isset($this->_errors[$component_name])) {
         $component->setErrorCode($this->_errors[$component_name]);
     }
     $this->_elements[$component_name] = $component;
     return $component;
 }
Esempio n. 2
0
 static function componentErrorMessage(IFormComponent $component)
 {
     return self::errorMessage($component->getErrorMessage(), $component->getName());
 }