Damian Crawford
Damian Crawford

Reputation: 45

view helper validation

ZF Manual on View Helpers

According to the above link I can create a form element in the view like so

echo $this->formText($name, $value, $attribs);

However how would I apply validation or does this need to be done in the controller using the validator component?

Upvotes: 3

Views: 285

Answers (2)

Tomáš Fejfar
Tomáš Fejfar

Reputation: 11217

Better solution is to use complete Zend_Form class to create the form and validate it.

Upvotes: 0

vascowhite
vascowhite

Reputation: 18440

If you did this:-

<form action='/login'>
echo $this->formText($name, $value, $attribs);
echo $this->formSubmit($name, $value, $attribs);
</form>

Then you would carry out the validation in the indexAction of your login controller using the validators available in Zend Validate.

Using this method you probably won't have a form object and I wouldn't really recommend using it unless you really don't like Zend Form.

So, basically that was just a long winded way of saying 'Yes this needs to be done in the controller using the validator component'.

Upvotes: 4

Related Questions