View Single Post
  #1 (permalink)  
Old 05-18-2008, 10:20 AM
persuses persuses is offline
Junior Member
 
Join Date: May 2008
Posts: 2
Default Custom Error Messages using Zend Decorators

I am having two problems with Zend Form and Zend Decorators that are driving me crazy.

I am trying to get this html structure when I get a form error:

<li class="error">
<label class="desc" for="name"> First Name </label>
<div>
<input class="field text half" name="name" type="text" value="" />
</div>
<p class="hint"> Your nickname </p>
<p class="error"> Error Message </p>
</li>

  1. I want to replace the <ul> and <li> elements of the error messages with a <p> element. And then to have it print out an error message at the bottom of the <li>.
  2. I want to add the class "error" to the <li> when it returns an error. I imagine the code will look something like the code below, but I can't figure it out.

if( $form->isValid($formData) ) {
...
} else {
$this->view->message = 'Validation Failed.';
$form->setElementDecorators(...);
}

Thanks so much for any help,
Daniel
Reply With Quote