Exemplo n.º 1
0
 /**
  * Add a form field
  * @param $label     Field Label
  * @param $object    Field Object
  * @param $size      Field Size
  * @param $validator Field Validator
  */
 public function addQuickField($label, AdiantiWidgetInterface $object, $size = 200, TFieldValidator $validator = NULL)
 {
     $object->setSize($size, $size);
     parent::addField($object);
     $object->setLabel($label);
     if (empty($this->currentRow) or $this->fieldPositions % $this->fieldsByRow == 0) {
         // add the field to the container
         $this->currentRow = $this->table->addRow();
     }
     $row = $this->currentRow;
     if ($validator instanceof TRequiredValidator) {
         $label_field = new TLabel($label . ' (*)');
         $label_field->setFontColor('#FF0000');
     } else {
         $label_field = new TLabel($label);
     }
     if ($object instanceof THidden) {
         $row->addCell('');
     } else {
         $row->addCell($label_field);
     }
     $row->addCell($object);
     if ($validator) {
         $object->addValidation($label, $validator);
     }
     $this->fieldPositions++;
     return $row;
 }
Exemplo n.º 2
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);
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Add a Form Field
  * @param $field Object
  */
 public function addField(AdiantiWidgetInterface $field)
 {
     if ($field instanceof GtkWidget) {
         $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));
         }
         $this->fields[$name] = $field;
         $field->setFormName($this->fname);
     }
 }