Example #1
0
 public function setup_validations()
 {
     parent::setup_validations();
     if ($this->required || !$this->blank) {
         $this->validations[] = "float";
     }
 }
Example #2
0
 public function validate()
 {
     parent::validate();
     if (!$this->blank) {
         $this->valid_format("email", '/^[_a-zA-Z0-9-]+(\\.[_a-zA-Z0-9-\\+]+)*@[a-zA-Z0-9-]+(\\.[a-zA-z0-9-]+)*(\\.[a-zA-Z]{2,4})$/i');
     }
 }
 public function testCanSetData()
 {
     $char = new CharField();
     $char->setData('test_data');
     $this->assertEquals($char->getRaw(), 'test_data');
     $this->assertEquals($char->getData(), 'test_data');
     $char->setName('test');
     $char->setErrorMessages(['error' => 'error message']);
     $this->assertTrue(is_array($char->getErrorMessages()));
     $this->assertEquals('test', $char->getName());
 }
 public function getFormField($form, $fieldClass = null, array $extra = [])
 {
     return parent::getFormField($form, \Mindy\Form\Fields\PasswordField::className(), $extra);
 }
Example #5
0
	function __construct ($name, $options = array()) {
		
		// Block having a default value
		unset($this->default);
		unset($options['default']);
		
		// Call the default constructor
		parent::__construct($name, $options);
		
	}
Example #6
0
 public function testCharFieldValidationErrorShouldSanitize()
 {
     try {
         $f = new CharField(array('regex' => '/^a/'));
         $f->clean('<xss></xss>bc');
     } catch (ValidationError $e) {
         $this->assertEquals('bc', $e->getCleanedValue());
     }
 }
Example #7
0
 /**
  * Validates field's errors and returns them as array
  * @return array
  */
 public function validate()
 {
     if (is_null($this->sourceField)) {
         $this->_addError("required option auto_source was not set");
     } elseif (!$this->getModel()->hasField($this->sourceField)) {
         $this->_addError("auto_source field '{$this->sourceField}' does not exists");
     }
     return parent::validate();
 }