-- Bob O <b...@electricgraffitti.com> wrote
(on Monday, 16 February 2009, 12:49 PM -0800):
> 
> Fantastic..That worked..thank you Matthew.
> 
> my final struggle is this
> 
> foreach ($this->_campaignCreateForm->getMessages() as $message) 
>                   {
>                   $this->flash(("Invalid Data: $message\n"), 'error',
> '/advertiser/create-campaign');
>                   }
> 
> returns the flash message, but the $message is simply an Array, and not the
> message set in the ini. So i think im confused there as well

Each validator can return an array of error messages, and each element
returns an array of elements that have error messages... So what you
need to do is traverse the entire thing.

There is a special FormErrors decorator used for this. You can grab
_just_ that content if you want:

    $form->addDecorator('FormErrors');
    $messages = $form->renderFormErrors();

> these are the messages i have set in the ini based on the particular
> validation.
> 
> advertiser.campaignCreate.elements.name.options.validators.notempty.options.messages.isEmpty
> = "A Campaign Name required."
> advertiser.campaignCreate.elements.name.options.validators.alpha.options.messages.notAlpha
> = "Invalid Campaign Name. Can only contain letters."
> 
> 
> 
> 
> Matthew Weier O'Phinney-3 wrote:
> > 
> > -- Bob O <b...@electricgraffitti.com> wrote
> > (on Saturday, 14 February 2009, 05:54 PM -0800):
> >> 
> >> If anyone could point me in a good direction that would be great
> >> 
> >> Im trying to get this form to validate
> > 
> > <snip - INI and view code> 
> > 
> >> this is my Controller code -
> >> 
> >>         $config = new Zend_Config_Ini(APPLICATION_PATH .
> >> '/config/campaignCreateForm.ini');
> >>         $this->_campaignCreateForm = new
> >> Zend_Form($config->advertiser->campaignCreate);
> >> 
> >> But im at a loss as to how the validations work? 
> > 
> > In your controller, pass data from the request to the form's isValid()
> > method:
> > 
> >     if
> > ($this->_campaignCreateForm->isValid($this->getRequest()->getPost())) {
> >         // Validates!
> >     }
> > 
> > -- 
> > Matthew Weier O'Phinney
> > Software Architect       | matt...@zend.com
> > Zend Framework           | http://framework.zend.com/
> > 
> > 
> 
> 
> -----
> Bob Hanson
> Web Developer
> SLC, UT
> -- 
> View this message in context: 
> http://www.nabble.com/Zend_Form%2C-Validators-%2C-Filters%2C-and-ini-files-tp22019106p22045553.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
> 

-- 
Matthew Weier O'Phinney
Software Architect       | matt...@zend.com
Zend Framework           | http://framework.zend.com/

Reply via email to