Zendcasts Forum

A community of developers who work with the Zend Framework and other enterprise PHP technologies

You are not logged in.

#1 2010-08-07 21:48:56

samik
New member
From: India
Registered: 2010-07-31
Posts: 9
Website

How to use Zend Validator to report various messages for an element

I want to add multiple validation rules and their associated error messages while creating a Zend Form element. Also want to list the error messages for all erroneous fields at the top of the form. How this can be achieved?
If I add some fields at run-time (e.g. qualification-1, 2 ... etc.) Is it possible to handle them and add suitable filters?

The other part is, if I want a client side validation using Zend jQuery support, is there any solve for inline and submit time validations? How to attach an AJAX related validation?

Last edited by samik (2010-08-07 21:51:59)

Offline

#2 2010-08-10 08:26:10

Jon Lebensold
Administrator
Registered: 2009-06-27
Posts: 279

Re: How to use Zend Validator to report various messages for an element

Hi Samik,

I think you're looking to user $form->getMessages() or $form->getErrorMessages() if you want to get the errors appearing on the top of your page.

adding fields dynamically is a little trickier, but is do-able if you use the zend_form methods to addElement() dynamically.

Hope that helps,
-
Jon

Offline

#3 2010-08-10 08:50:22

samik
New member
From: India
Registered: 2010-07-31
Posts: 9
Website

Re: How to use Zend Validator to report various messages for an element

Thank you sir, for your suggestion. I shall try to elaborate my desire.

A single field may have multiple validation rules. For example a text field for taking user-name may have the following validations.

1. Required
2. must be alpha-numeric
3. single word
4. greater than 6 characters

so each validation should have different messages like

1. Please enter user-name
2. User-name must be alpha-numeric
3. It must be a single word
4. Please provide at least 6 characters.

So according to the actual invalid situation the message should be displayed. Not all at a time. or not only one for all errors. I am not able to script this situation.

Please help me out this thing.

Offline

Board footer

Powered by FluxBB