/** * @inheritDoc */ public function __construct($key, array $options = array()) { $this->addOption('virtual', false); parent::__construct($key, $options); }
/** * Constructor. * * @param string $name * @param array $options */ public function __construct($name = null, array $options = array()) { $this->addOption('data_class'); $this->addOption('data_constructor'); $this->addOption('csrf_field_name', '_token'); $this->addOption('csrf_provider'); $this->addOption('field_factory'); $this->addOption('validation_groups'); $this->addOption('virtual', false); $this->addOption('validator'); $this->addOption('context'); $this->addOption('by_reference', true); if (isset($options['validation_groups'])) { $options['validation_groups'] = (array) $options['validation_groups']; } if (isset($options['data_class'])) { $this->dataClass = $options['data_class']; } if (isset($options['data_constructor'])) { $this->dataConstructor = $options['data_constructor']; } parent::__construct($name, $options); // Enable CSRF protection if ($this->getOption('csrf_provider')) { if (!$this->getOption('csrf_provider') instanceof CsrfProviderInterface) { throw new FormException('The object passed to the "csrf_provider" option must implement CsrfProviderInterface'); } $fieldName = $this->getOption('csrf_field_name'); $token = $this->getOption('csrf_provider')->generateCsrfToken(get_class($this)); $this->add(new HiddenField($fieldName, array('data' => $token))); } }
/** * Constructor * * @see FieldInterface::__construct() */ public function __construct($key, array $options = array()) { // set the default renderer before calling the configure() method $this->setRenderer(new TableRenderer()); parent::__construct($key, $options); }