/** * Constructor. * * @param string $name * @param array|object $data * @param ValidatorInterface $validator * @param array $options */ public function __construct($name, $data = null, ValidatorInterface $validator = null, array $options = array()) { $this->validator = $validator; // Prefill the form with the given data if (null !== $data) { $this->setData($data); } $this->addOption('csrf_protection'); $this->addOption('csrf_field_name', '_token'); $this->addOption('csrf_secrets', array(__FILE__ . php_uname())); $this->addOption('field_factory'); $this->addOption('validation_groups'); if (isset($options['validation_groups'])) { $options['validation_groups'] = (array) $options['validation_groups']; } parent::__construct($name, $options); // If data is passed to this constructor, objects from parent forms // should be ignored if (null !== $data) { $this->setPropertyPath(null); } // Enable CSRF protection, if necessary if ($this->getOption('csrf_protection')) { $field = new HiddenField($this->getOption('csrf_field_name'), array('property_path' => null)); $field->setData($this->generateCsrfToken($this->getOption('csrf_secrets'))); $this->add($field); } }
/** * Constructor. * * @param string $name * @param array|object $data * @param ValidatorInterface $validator * @param array $options */ public function __construct($name, $data, ValidatorInterface $validator, array $options = array()) { $this->validator = $validator; $this->setData($data); if (self::$defaultCsrfProtection !== false) { $this->enableCsrfProtection(); } if (self::$defaultLocale !== null) { $this->setLocale(self::$defaultLocale); } parent::__construct($name, $options); }
/** * Constructor. * * @param string $name * @param array|object $data * @param ValidatorInterface $validator * @param array $options */ public function __construct($name, $data, ValidatorInterface $validator, array $options = array()) { $this->validator = $validator; $this->setData($data); if (FormConfiguration::isDefaultCsrfProtectionEnabled()) { $this->enableCsrfProtection(); } if (FormConfiguration::getDefaultLocale() !== null) { $this->setLocale(FormConfiguration::getDefaultLocale()); } parent::__construct($name, $options); }
/** * Constructor. * * @param string $name * @param array|object $data * @param ValidatorInterface $validator * @param array $options */ public function __construct($name, $data = null, ValidatorInterface $validator = null, array $options = array()) { $this->validator = $validator; // Prefill the form with the given data if (null !== $data) { $this->setData($data); } if (FormConfiguration::isDefaultCsrfProtectionEnabled()) { $this->enableCsrfProtection(); } parent::__construct($name, $options); // If data is passed to this constructor, objects from parent forms // should be ignored if (null !== $data) { $this->setPropertyPath(null); } }
/** * Constructor. * * @param array $defaults An array of field default values * @param array $options An array of options * @param string $defaultCsrfSecret A Csrf secret */ public function __construct($name, $object, ValidatorInterface $validator, array $options = array()) { $this->generator = new HtmlGenerator(); $this->validator = $validator; $this->setData($object); $this->setCsrfFieldName(self::$defaultCsrfFieldName); if (self::$defaultCsrfSecret !== null) { $this->setCsrfSecret(self::$defaultCsrfSecret); } else { $this->setCsrfSecret(md5(__FILE__ . php_uname())); } if (self::$defaultCsrfProtection !== false) { $this->enableCsrfProtection(); } if (self::$defaultLocale !== null) { $this->setLocale(self::$defaultLocale); } if (self::$defaultTranslator !== null) { $this->setTranslator(self::$defaultTranslator); } parent::__construct($name, $options); }
/** * Repeats the given field twice to verify the user's input * * @param FieldInterface $innerField */ public function __construct(FieldInterface $innerField, array $options = array()) { $this->prototype = $innerField; parent::__construct($innerField->getKey(), $options); }