triggering invalid message with zend_dojo elements on post fail - zend-framework

I am having a few issues with a Zend_Form that I have which uses Dojo elements to handle user validation.
The scenario is when are user fills in the form the dojo elements ensure the formatting is correct. On post of the form if there is an error such as the email address already existing in the database, my code throw an exception that I catch, I want to then use the dojo validation to display the error rather than having error messages at the top or bottom of the form.
I've tried the following:
catch(Exception $e){
$signupForm->populate($formData);
$signupForm->getElement('email')->setInvalidMessage('email addresss already exists');
$this->view-form = $signupForm;
}
This redisplays the form but does not highlight the dojo element to show what element is failing. How can this be done or am I going to have to display the error messages somewhere on the form in an list?
Any help would be gratefully received.

Did you take a look at Zend_Dojo_Form?

Related

using Ajax , dropdownlist and page validation

using Ajax I filled Country, State and city dropdownlist. On land change state is filled and on state change city is filled properly.
Then when I try to save page I face this :Invalid postback or callback argument.
Searched and found out that this is due to change in ddl.selectedvalu change from initial value that is assigned by asp.net.
Now my question is that how can I let asp.net know that the new ddl value is valid?
Thank you.
In many pages it is recommended to use EnableEventValidation="false", but I prefer not to use it.
Some say that use Render and add value to notify .Net like this:
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
ClientScript.RegisterForEventValidation("ddlLanguages ", "English");
ClientScript.RegisterForEventValidation("ddlLanguages ", "Tamil");
ClientScript.RegisterForEventValidation("ddlLanguages ", "Hindi");
base.Render(writer);
}
but how to use it? where to put it?
for a better understanding I put here a sample code including Database script :
hesab20.com/DownLoad/Ajax.zip
in this sample Javascript is used to fill drop-down list . But when click button is executed and a post back occur, error happen.
Please help if you have experience with this.
Regards.
Please run the sample code and change the drop down lists , automatically the other is filled , meaning that list item text and value is completely changed. finally click button for a post back.
you must see that error happens:
Invalid postback or callback argument. Event validation ....
and note : EnableEventValidation="true"
Thanks

No validations errors to display in symfony 1.4 form

I have a problem with all my forms in symfony 1.4. They work with good datas, my new objects are created ... But when i give bad datas, my forms do nothing as expected but have no errors.
My code in my action :
$this->form = new EtablissementForm();
$this->form->bind(
$request->getParameter($this->form->getName()),
$request->getFiles($this->form->getName())
);
Edit :
Solved. I guess i need some sleep. This was really a dumb mistake. I was sure i had removed a new E...Form(); In my view for my action, actually i did it ... in another file.
So my $form was overwritten by an empty form. So the problem is solved.
if ($this->form->isValid())
{
//some things and a redirect
}
In a nutshell, my form works with good datas. But i don't have any errors to display when i'm giving bad datas. And my form don't add something in my database. Validations works cause it raise exception in bind, but i just get an empty form to display.
Your view needs to have proper scope to $form. Your code above may be incomplete. In the action you show above, if the action ends, and you go to your view, and your view has the following, your validation errors should appear inline with your form.
<?php echo $form ?>

Wicket: How to post a Feedback Message from within the FeedbackPanel

I have a form with ComponentFeedbackPanels. I have implemented a Filter, that removes the FeedbackMessage shown in the ComponentFeedbackPanels (I have adapted this solution) from the top-of-the-page FeedbackPanel.
Now I would like to add a Feedback Message to the top level to remind the users to read CompnoentFeedback Messages that are displayed next to the form fields.
I don't know how to add such a message. Calling error() from within that filter or FeedbackPanel or the parent page when already filtering does not add anything to the current FeedbackPanel...
To add a top-level message, use Session.get().error(message).

How to show just one (e.g. the first) error message to a form field with Zend framework where validation has failed?

Is there any way to do that with a decorator or do I need to dig deeper into ZF?
If you have multiple validators attached to one form element and want only the first error message to pop up, you can set breakChainOnFailure option to TRUE for each validator. In this case, if one of the validators fails, all the subsequent validators are skipped.
$element->addValidator(
new Zend_Validate_StringLength(array('min' => 6, 'max' => 12)),
true)
->addValidator(new Zend_Validate_Alnum());
if $foo is in an instance of Zend_Form and there is an form element username inside this form then
$foo->username->getMessages() ; will return array of errors messages to show only one you simply need to do array_pop($foo->username->getMessages()); . Basically zend decorators uses error view helper to display the messages . You need to extend the default decorator and remove the view helper simply by echo
There are many ways you can do this. My personal favorite is to extend the validator you want to use to only return one custom message. For the email validator this is especially helpful since it shows some crazy error messages that you may not want to show anyway. You can see this method here: http://clintberry.com/2010/07/zend-form-email-validator-customizing-error-messages/

why aren't error messages showing on zend_form if validation fails?

I'm trying to get the standard error messages to show up in zend_form but they don't.
I have this:
if ($form->isValid($formData)) {
// do stuff
} else {
$form->populate($formData);
$this->view->form = $form;
}
When I post an invalid form, the form does show up in the view like it's supposed to, but from the tutorials it seems like error messages should show up by default?
What am I missing?
Thank you for your help!
The error messages are applied using Decorator Pattern. There are some Zend Form Element Decorators present in the form by default.
I guess you have overwritten the default decorators, using e.g. setDecorators().