Exemplo n.º 1
0
 /**
  * Add a Form Field
  * @param $field Object
  */
 public function addField(AdiantiWidgetInterface $field)
 {
     if ($field instanceof TField) {
         $name = $field->getName();
         if (isset($this->fields[$name])) {
             throw new Exception(AdiantiCoreTranslator::translate('You have already added a field called "^1" inside the form', $name));
         }
         if ($name) {
             $this->fields[$name] = $field;
             $field->setFormName($this->name);
             if ($field instanceof TButton) {
                 $field->addFunction($this->js_function);
             }
         }
     }
     if ($field instanceof TMultiField) {
         $this->js_function .= "mtf{$name}.parseTableToJSON();";
         if ($this->fields) {
             // if the button was added before multifield
             foreach ($this->fields as $field) {
                 if ($field instanceof TButton) {
                     $field->addFunction($this->js_function);
                 }
             }
         }
     }
 }