/** * Constructor. * * @access public * @param string $name field name * @param Form $form form * @throws Exception * @since 1.0.0-alpha * @version 1.0.0-alpha */ public function __construct($name, Form $form) { $this->name = $name; $this->oForm = $form; $this->oAttributes = Helper\Attributes::factory(); $this->resetAllNeededAttributes(); $this->bFormSubmitted = $this->getFormObject()->isSubmitted(); // add particular field to form (if not a singleton) if ($form->getName() !== 'singletons') { if (!$form->hasField($name)) { $form->addField($this); } else { throw new Exception('Form "' . $form->getName() . '" already has field with name "' . $this->getName() . '".'); } } }