src/Forms/FormField.php
public function addValidator($validator)
    {
        if ($validator === FormField::TYPE_FILE)
        {
            $this->is_file = true;
            $validator = Type::RESOURCE;
        }

        if (!$validator instanceof Validator)
        {
            $validator = new Validator($validator, ['unstrict' => true]);
        }

        $this->validators[] = $validator;
        return $this;
    }
public function addValidator($validator)
    {
        if ($validator === FormField::TYPE_FILE)
        {
            $this->is_file = true;
            $validator = Type::RESOURCE;
        }

        if (!$validator instanceof Validator)
        {
            $validator = new Validator($validator, ['unstrict' => true]);
        }

        $this->validators[] = $validator;
        return $this;
    }
public function addValidator ( $ validator ) { if ( $ validator === FormField :: TYPE_FILE ) { $ this -> is_file = true ; $ validator = Type :: RESOURCE ; } if ( ! $ validator instanceof Validator ) { $ validator = new Validator ( $ validator , [ 'unstrict' => true ] ) ; } $ this -> validators [ ] = $ validator ; return $ this ; }
Change the type of the field
@param Validator $validator The validator to add. Provide either
one of the constants in Type, or a instantiated
Validator. FormField::TYPE_FILE will be transparently
converted to a file upload form field.
@return FormField Provides fluent interface
Change the type of the field