private function getSingleFieldName(ElementInterface $element) { if (count($this->cloneable->getBaseElements()) > 1) { return $this->cloneable->getName() . '[' . $this->rowIndex . '][' . $element->getName() . ']'; } return $this->cloneable->getName() . '[]'; }
/** * Adds an element to the form, if element has DecoratedInterface, injects DI * * @param \Phalcon\Forms\ElementInterface $element * @param string $postion * @param bool $type If $type is TRUE, the element wile add before $postion, else is after * @return \Phalcon\Forms\Form */ public function add(ElementInterface $element, $postion = null, $type = null) { if ($element instanceof Decorator\DecoratedInterface && $element->getDecorator() instanceof DecoratorInterface) { $element->getDecorator()->setDI($this->di); } $reflectionClass = new \ReflectionClass($element); $elementType = strtolower(str_replace($reflectionClass->getNamespaceName() . '\\', '', $reflectionClass->getName())); $element->setUserOption('_type', $elementType); // hax even when $postion and $type are null by default, call parent::add($element, $postion, $type) // causes exception : Array position does not exist if (!is_null($postion) || !is_null($type)) { return parent::add($element, $postion, $type); } else { return parent::add($element); } }
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; }
/** * Render in HTML an element of type Submit * @param \Phalcon\Forms\ElementInterface $element * @return string */ function _renderButton($element) { $elementClasses = 'btn waves-effect ' . $element->getAttribute('class', ''); $element->setAttribute('class', $elementClasses); $html = $this->render($element->getName()); return $html; }
/** * Render in HTML an element of type Submit * @param \Phalcon\Forms\ElementInterface $element * @return string */ function _renderSubmit($element) { $elementClasses = "btn btn-default " . $element->getAttribute("class", ""); $element->setAttribute("class", $elementClasses); $html = $this->render($element->getName()); return $html; }
/** * 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); }
/** * Add one element to base elements array. * * @param \Phalcon\Forms\ElementInterface $element * @return $this */ public function addBaseElement(\Phalcon\Forms\ElementInterface $element) { $this->baseElements[$element->getName()] = $element; return $this; }