示例#1
0
 /**
  * Test the DateTime filters
  */
 public function testDateTime()
 {
     $control = new Entry('date');
     $control->setValue('31/12/2016');
     $filter = new Filter($control, '32/13/2016');
     $this->assertInstanceOf(DateTime::class, $filter->getDateTime('d/m/Y'));
 }
示例#2
0
 /**
  * This method allow you to quickly add an CSRF hidden control to your form, but you can
  * add one yourself by another method.
  *
  * @param string $string
  * @return Form
  */
 public function addSecurityControl(string $string) : self
 {
     $security = new Entry('security-string');
     $security->setAttribute('type', 'hidden');
     $security->setDisplay(['control']);
     $security->setValue($string);
     $security->addConstraint(function (Constraint $constraint) use($string) {
         $constraint->setError('Failed to validate the CSRF security string in your provided entries.');
         return $constraint->isSameAs($string);
     });
     $this->addControl($security);
     return $this;
 }