/** * adds an element to the group * @param Element $element the element to add */ public function addElement(Element $element) { $iname = 'i' . count($this->elements); $this->elements[$iname] = $element; $element->setParent($this); $element->setInternalName($iname); }
public function elementDefaultRender(Element $element) { if ($element instanceof Element\Drawable) { return $element->render($this->getLocalValue(), $this->getLocalValue()); } else { throw new \UForm\Exception("Trying to render an invalid element. Element not implementing Drawable cant be rendered"); } }
public function __construct($name, Element $elementDefinition, $min = 1, $max = -1) { parent::__construct($name); $this->elementDefinition = $elementDefinition; $this->min = $min; $this->max = $max; $this->elementDefinition->setName(null); $this->addSemanticType("collection"); }
/** * Binds the given input with its title * @param Element $element * @param $label */ protected function _makeInput(Element $element, $label, $defaultValue) { if (null !== $label) { $element->setOption('label', $label); } if (null !== $defaultValue) { $element->addFilter(new DefaultValue($defaultValue)); } }
public function childrenAreValid() { if ($this->element instanceof Container) { foreach ($this->element->getElements($this->getValue()) as $element) { if (!$this->formContext->elementIsValid($element)) { return false; } if (!$this->formContext->childrenAreValid($element)) { return false; } } } return true; }
public function __construct($name) { parent::__construct($name); $this->addSemanticType('primary'); }
/** * @inheritdoc */ public function setParent(Container $parent) { $r = parent::setParent($parent); foreach ($this->getElements() as $element) { $element->refreshParent(); } return $r; }
/** * @param Element $element * @param FormContext $formContext * @return string * @throws \Exception * @throws \Twig_Error_Loader */ public function renderElement(Element $element, FormContext $formContext) { $semanticTypes = $element->getSemanticTypes(); return $this->renderElementAs($element, $formContext, $semanticTypes); }
/** * Get the children of the current element * @return \UForm\Form\Element[] */ public function getMessages() { return $this->formContext->getChainedValidation()->getValidation($this->element->getInternalName(true), true)->getMessages(); }
/** * Binds the given input with its title * @param Element $element * @param $title */ protected function _makeInput(Element $element, $title) { if (null !== $title) { $element->setOption("title", $title); } }
public function __construct($name, $attributes = null, $validators = null, $filters = null) { parent::__construct($name, $attributes, $validators, $filters); $this->addSemanticType("primary"); }
/** * @inheritdoc */ public function sanitizeData($data) { $data = parent::sanitizeData($data); foreach ($this->getElements($data) as $element) { $name = $element->getName(); if ($name) { if (isset($data[$name])) { $data[$name] = $element->sanitizeData($data[$name]); } } else { $data = $element->sanitizeData($data); } } return $data; }