2010年9月12日星期日

Re: [fw-mvc] Validating ajax with Zend_Rest_Route?

Hi,

I don't think you will need a separate action for validation. Each action will do the validation on its own. 

So something like this:
public function newAction()
{
  //get $data from request
  //build $form object
  if($form->isValid($data)) { 
    //more processing here
  } else {
    //return error
  }
}

- Tuan Ngo


On Mon, Sep 13, 2010 at 6:17 AM, Christian Heinrich <christian@gladbachcity.de> wrote:
Hi all,

first of all, hopefully my problem is not totally wrong here. I decided to post it here as it seemed more appropriate than in fw-general.

My problem:
I use the MVC-stack and I decided to do validation via ajax and the
Zend_Form component, as Zend_Form supports this via processAjax().

However, I thought it would be a good idea to make the controllers that
are related to CRUD operations RESTful.

Said that, Zend_Rest_Route only supports 7 actions (new, edit, get, put, post, delete, index).
But - where am I supposed to put the validation stuff? (Of course, the validation itself won't be done by the controller but by the models.
The controller will only call the appropriate methods, e.g. $form->processAjax(...)).

I mean, putting it - for example - into the PUT action seems somehow
unnatural to me? Or is this the way it should be? I'm actually missing
some kind of "validateAction" or something. However, it might be the
case that I got something severely wrong, so any hint and advise is
highly appreciated.

Thanks in advance
Christian


没有评论: