コード例 #1
0
ファイル: form_element.php プロジェクト: 2626suke/curryfw
 /**
  * Set message of input error
  *
  * @param string $errorMessage
  * @return HtmlElement
  */
 public function setErrorMessage($errorMessage)
 {
     $this->_errorMessage = $errorMessage;
     if ($this->_parentLayout instanceof FormLayoutAbstract) {
         if ($errorMessage == '') {
             if ($this->_errorContainer instanceof HtmlElement) {
                 $this->_parentLayout->removeErrorContainer($this, $this->_errorContainer);
             }
             $this->_errorContainer = null;
         } else {
             if (!$this->_errorContainer instanceof HtmlElement) {
                 $this->_errorContainer = $this->_parentLayout->addErrorContainer($this, $errorMessage);
             } else {
                 $this->_errorContainer->setText($errorMessage);
             }
         }
     }
     return $this;
 }
コード例 #2
0
 /**
  * Create and add container tag of error message to layout
  * 
  * @param FormElement $formElement
  * @param string $errorMessage
  * @return HtmlElement
  */
 public function addErrorContainer(FormElement $formElement, $errorMessage)
 {
     $errorContainer = new HtmlElement($this->_errorTagName);
     $errorContainer->setClass($this->_errorClass);
     $errorContainer->setText($errorMessage);
     $inputContainer = $formElement->getInputContainer();
     $inputContainer->addElement($errorContainer);
     return $errorContainer;
 }
コード例 #3
0
ファイル: html_element.php プロジェクト: 2626suke/curryfw
 /**
  * Create element by tag setting array
  * 
  * @param array $setting
  * @return HtmlElement
  */
 protected static function _createElement($setting)
 {
     if (!isset($setting['tag_name'])) {
         throw new Exception('Specification of "tag_name" is required, but not specified.');
     }
     $elem = new HtmlElement($setting['tag_name']);
     if (isset($setting['attributes'])) {
         if (!is_array($setting['attributes'])) {
             throw new Exception('Specification of "attributes" in element setting must be an array, ' . gettype($setting['attributes']) . ' given.');
         }
         $elem->setAttributes($setting['attributes']);
     }
     if (isset($setting['is_empty'])) {
         $elem->setIsEmptyTag($setting['is_empty']);
     }
     if (isset($setting['nodes'])) {
         if ($elem->isEmptyTag()) {
             throw new Exception('Empty tag cannot contain node.');
         }
         if (!is_array($setting['nodes'])) {
             throw new Exception('Specification of "nodes" in element setting must be an array, ' . gettype($setting['nodes']) . ' given.');
         }
         foreach ($setting['nodes'] as $node) {
             if (is_array($node)) {
                 $subElem = self::_createElement($node);
                 $elem->addElement($subElem);
             } else {
                 $elem->addText($node);
             }
         }
     }
     if (isset($setting['text'])) {
         if ($elem->isEmptyTag()) {
             throw new Exception('Empty tag cannot contain node.');
         }
         if (is_array($setting['text']) || is_object($setting['text'])) {
             throw new Exception('Specification of "text" in element setting must be string, ' . gettype($setting['text']) . ' given.');
         }
         $elem->setText($setting['text']);
     }
     return $elem;
 }