示例#1
0
 /**
  * Adds javascript rules to element
  *
  * @param ElementInterface    $element
  * @param AttributeCollection $collection
  */
 protected function addElementRules(ElementInterface $element, AttributeCollection $collection)
 {
     if ($element->hasOption('rules') && count($element->getOption('rules'))) {
         $rules = $this->formatter->formatRules($element->getOption('rules'));
         $collection->add(new Attribute('aoRules', $rules, Attribute::TYPE_ARRAY));
     }
 }
 /**
  * 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);
 }