Пример #1
0
 /**
  * Constructor
  *
  * @param Form   $form  Form
  * @param string $name  Name
  * @param mixed  $value Initial value
  */
 public function __construct(Form $form, $name, $value = null)
 {
     $this->form = $form;
     $this->validators = array();
     $this->filters = array();
     $this->valid = true;
     $this->binds = array();
     $this->setName($name);
     $this->setValue($value);
     $form->addField($this);
 }
Пример #2
0
 /**
  * Constructor
  *
  * @param Form     $form    Base form
  * @param string   $name    Unique name
  * @param array    $values  Values to be binded
  * @param callable $creator Fields creator
  * @param callable $updater Binded values updater
  *
  * @throws \InvalidArgumentException
  */
 public function __construct(Form $form, $name, $values, $creator, $updater)
 {
     $this->form = $form;
     $this->name = $name;
     $this->values = Value::isArray($values) ? $values : (array) $values;
     if (!is_callable($creator)) {
         throw new \InvalidArgumentException(sprintf("Form bind '%s' creator is not callable.", $this->name));
     }
     $this->creator = $creator;
     if (!is_callable($creator)) {
         throw new \InvalidArgumentException(sprintf("Form bind '%s' updater is not callable.", $this->name));
     }
     $this->updater = $updater;
     $form->addBind($this);
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function inject($object, $except = array())
 {
     if (!in_array(static::METADATA, $except)) {
         $except[] = static::METADATA;
     }
     return parent::inject($object, $except);
 }