/** * Maps data to single element * * @param mixed $data * @param ElementInterface $child */ protected function mapRequestDataToElement($data, ElementInterface $child) { $child->setValue($data); $children = $child->getChildren(); if ($children->count()) { $this->mapRequestDataToElementCollection($data, $children); } }
/** * Adds javascript children to element * * @param ElementInterface $element * @param AttributeCollection $collection */ protected function addElementChildren(ElementInterface $element, AttributeCollection $collection) { $children = $element->getChildren(); if ($children->count()) { $attribute = new Attribute('aoFields', $this->renderChildren($children), Attribute::TYPE_ARRAY); $collection->add($attribute); } }
/** * Renders single form element with additional attributes * * @param ElementInterface $element * * @return array */ protected function renderElement(ElementInterface $element) { $children = $element->getChildren(); $collection = $this->getAttributesCollection($element); if ($children->count()) { $attribute = new Attribute('aoFields', $this->renderChildren($children), Attribute::TYPE_ARRAY); $collection->add($attribute); } if ($element->hasOption('dependencies') && count($element->getOption('dependencies'))) { $dependencies = $this->formatter->formatDependencies($element->getOption('dependencies')); $collection->add(new Attribute('agDependencies', $dependencies, Attribute::TYPE_ARRAY)); } if ($element->hasOption('rules') && count($element->getOption('rules'))) { $rules = $this->formatter->formatRules($element->getOption('rules')); $collection->add(new Attribute('aoRules', $rules, Attribute::TYPE_ARRAY)); } return $this->formatter->formatAttributesCollection($collection); }
/** * Sets errors on element * * @param array $messages * @param ElementInterface $element */ protected function mapMessagesToElement(array $messages, ElementInterface $element) { if ($element->hasPropertyPath()) { $propertyPathParts = explode('.', $element->getPropertyPath(false)); $propertyPath = $this->buildPath($propertyPathParts); if ($this->propertyAccessor->isReadable($messages, $propertyPath)) { $errors = $this->propertyAccessor->getValue($messages, $propertyPath); $element->setError($errors); } } $children = $element->getChildren(); if ($children->count()) { $this->mapMessagesToElementCollection($messages, $children); } }