Exemplo n.º 1
0
 /**
  * @param InputElement $element
  * @return string
  */
 protected function generateFormBuilderChain(InputElement $element)
 {
     $parts = array();
     $data = $element->toArray();
     $parts[] = sprintf('%s(\'%s\')', $element->getType(), $element->getName());
     unset($data['type']);
     unset($data['name']);
     foreach ($data as $name => $value) {
         if (!$value) {
             continue;
         }
         if (is_numeric($value)) {
             $part = sprintf('%s(%s)', $name, $value);
         } else {
             $part = sprintf('%s(\'%s\')', $name, $value);
         }
         $parts[] = $part;
     }
     return implode('->', $parts) . ';';
 }
Exemplo n.º 2
0
 /**
  * @param       $element
  * @return InputElement
  */
 protected function addElement(InputElement $element)
 {
     $reference = $this;
     $name = $element->getName();
     Event::fire('formBuilder.addElement.pre', compact('name', 'element', 'reference'));
     $this->elements[$name] = $element;
     Event::fire('formBuilder.addElement.post', compact('name', 'element', 'reference'));
     return $element;
 }