I am a newbie in zendframework. I am using zendframework version 2.
I have a ClientForm class which is inheriting from Zend\Form\Form.
class Client extends Form
{
public function __construct($name = null, $options = array())
{
if (null == $name) $name = 'ClientFrom';
parent::__construct($name, $options);
$this->add(array(
'name' => 'clientName',
'type' => 'Text'
));
$this->add(array(
'name' => 'address1',
'type' => 'Text'
));
}
}
I need to implement validation and filtering for the above form.
Rules for Validation
'clientName' => required, min = 3, max = 25
Rules for Filter
'clientName' => [a-zA-Z0-9_ ]
Questions
- Can I implement this rules and filter in the same class as Form (without creating a new input filter class)
- Please show me example on how to implement above rules on my above class.
Thank you.