Exemple #1
0
 /**
  * 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);
 }
Exemple #2
0
 /**
  * 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);
 }