I am using Symfony 1.3.6 on Ubuntu.
I have a form with a lot of fields on it - rather than showing all the fields in one go (which may intimidate the user), I want to br
The function isValid()
doesn't really do anything, except check if the associated form has been bound and that the total number of validator errors is 0. The actual validation is done during the "binding" stage ($form->bind()
).
After binding, validator errors are stored in each field of the form(sfFormField). So, to get the individual errors of form fields, you can do something like this:
hasError()) {
// do something
}
}
?>
Or, since in your case you need to deal with only a restricted set of fields, try to iterate over an array of field names instead:
hasError()) {
// do something
}
}
?>
This can easily be adapted into a function, say validateFields($fieldNames)
that meets DRY expectations.
Check the documentation for sfFormField to see what other information you can get from a field.