/** * 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); }