Esempio n. 1
0
 public function addElement(ElementInterface $element, $label, $attributes = null)
 {
     if (is_array($attributes) && !isset($attributes['id'])) {
         $attributes['id'] = null;
     }
     if (!is_null($attributes)) {
         $element->setAttributes($attributes);
     }
     $element->setLabel($label);
     $this->add($element);
     return $this;
 }
Esempio n. 2
0
 /**
  * Add element to form
  *
  * @param FElementInterface $element
  * @param string $position
  * @param bool $type If $type is TRUE, the element wile add before $position, else is after
  * @return \ZCMS\Core\Forms\ZForm
  */
 public function add(FElementInterface $element, $position = null, $type = null)
 {
     if ($this->bootstrap) {
         $class = $element->getAttribute("class");
         $classes = array_map("trim", explode(" ", $class));
         if (!in_array("form-control", $classes)) {
             $element->setAttribute("class", "form-control " . $class);
         }
     }
     if ($this->_autoGenerateTranslateLabel && $this->_formName != null) {
         $title = __($this->_formName . '_' . $element->getName());
         $attributes = $element->getAttributes();
         if (isset($attributes['required'])) {
             $title .= ' <span class="symbol required"></span>';
         }
         $element->setLabel($title);
     }
     return parent::add($element, $position, $type);
 }