Esempio n. 1
0
 public function getInputFilter()
 {
     if (!$this->inputFilter) {
         $input = new Input();
         $input->setName('entities');
         $input->setRequired(false);
         $this->inputFilter = new RealInputFilter();
         $this->inputFilter->add($input);
     }
     return $this->inputFilter;
 }
Esempio n. 2
0
 public function getInputFilter()
 {
     $inputFilter = new InputFilter();
     $username = new Input();
     $username->setName('username')->setRequired(true);
     $username->setErrorMessage('A Username is required to Login');
     $inputFilter->add($username);
     $password = new Input();
     $password->setName('password')->setRequired(true);
     $password->setErrorMessage('A Password is required to Login');
     $inputFilter->add($password);
     return $inputFilter;
 }
Esempio n. 3
0
 /**
  * @param ServiceLocatorInterface $serviceLocator
  *
  * @return InputFilter
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $username = new Input();
     $username->setName('username');
     $username->setRequired(true);
     $username->setAllowEmpty(false);
     $username->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
     $password = new Input();
     $password->setName('password');
     $password->setRequired(true);
     $password->setAllowEmpty(false);
     $password->getFilterChain()->attach(new StringTrim())->attach(new StripTags());
     $password->getValidatorChain()->attach($serviceLocator->get('UghAuthentication\\Authentication\\Validator\\Authentication'));
     $inputFilter = new InputFilter();
     $inputFilter->add($username);
     $inputFilter->add($password);
     return $inputFilter;
 }
Esempio n. 4
0
 /**
  * Manually override the default control name for this field.
  *
  * This can be useful and necessary if you are using multiple instances of
  * the same model and field on a single page and you need to disambiguate
  * them.
  *
  * @param string $controlName
  * @return \Dewdrop\Db\Field
  */
 public function setControlName($controlName)
 {
     $this->controlName = $controlName;
     if ($this->inputFilter) {
         $this->inputFilter->setName($this->controlName);
     }
     return $this;
 }
 public function testInputFilterValidates()
 {
     $baddata = '1234';
     $gooddata = '12345';
     $tableName = 'sometable';
     $service = new AggregateEntityFilterService();
     $service->setBaseTable($tableName);
     $entityFilter = new BaseEntityFilterService();
     $entityFilter->setTableName($tableName);
     $input = new Input();
     $input->setName('name')->setAllowEmpty(FALSE)->getValidatorChain()->attach(new StringLength(5));
     $inputFilter = new InputFilter();
     $inputFilter->add($input);
     $entityFilter->setInputFilter($inputFilter);
     $entityFilter->setData(array('name' => $baddata));
     $service->add($entityFilter);
     $this->assertFalse($service->isValid(), 'Should have failed filter input validator');
     $service = new AggregateEntityFilterService();
     $service->setBaseTable($tableName);
     $entityFilter->setData(array('name' => $gooddata));
     $service->add($entityFilter);
     $this->assertTrue($service->isValid(), 'Should have passed filter input validator');
 }