Ejemplo n.º 1
0
 /**
  * Add a hidden input field to the form collection.
  *
  * Hidden fields can be used for example to inject custom values in your post data and still have
  * them validated using ValidForm Builder.
  *
  * @param string $name The hidden field's `name` attribute
  * @param string $type Define a validation type using one of the `ValidForm::VFORM_` constants. This does **not**
  * influence the fact that you're creating a hidden field. This is only used for validation of the hidden field's
  * content.
  * @param array $meta Optional meta array
  * @param boolean $blnJustRender If true, only create a {@link \ValidFormBuilder\Hidden} instance and return it.
  * When false, this {@link \ValidFormBuilder\Hidden} instance is added to the internal `elements` collection
  * and will be parsed when `toHtml()` is called.
  *
  * @return \ValidFormBuilder\Hidden
  */
 public function addHiddenField($name, $type, $meta = array(), $blnJustRender = false)
 {
     $objField = new Hidden($name, $type, $meta);
     if (!$blnJustRender) {
         // *** Fieldset already defined?
         $objFieldset = $this->__elements->getLast("ValidFormBuilder\\Fieldset");
         if ($this->__elements->count() == 0 || !is_object($objFieldset)) {
             $objFieldset = $this->addFieldset();
         }
         $objField->setMeta("parent", $objFieldset, true);
         // *** Add field to the fieldset.
         $objFieldset->addField($objField);
     }
     return $objField;
 }