Hi! I have a "wizard" in my admin generator that ajax posts to multiple different modules to step the user through creating objects in the correct order.
I'm using the generated actions, so I post to (in one example) "facility/create" and the object is created. Works like a charm, except that there is no feedback. I'm having some trouble determining how to build the response. The generated executeCreate action calls processForm, and processForm is hardcoded to redirect to facility/edit if the insertion is successful. This is not the behavior that I want when I'm using ajax. I just want a little JSON back. I could override processForm(), or redirect() in all the actions, but that seems like too much redundant code (I'm creating objects like this in several modules). It seems as if there should be some good way to suppress or block the redirect. Is there a good way to keep processForm from redirecting to the edit page? and/or Is there a better way to accomplish the ajax creates? thanks! class facilityActions extends autoFacilityActions { //I can't do this because processForm redirects. public function executeCreate(sfWebRequest $request) { parent::executeCreate($request); if($isAjax = $this->getRequest()->isXmlHttpRequest()) { return $this->renderText(json_encode(array ('status'=>'error'))); } } } class autoFacilityActions extends sfAction { protected function processForm(sfWebRequest $request, sfForm $form) { $form->bind($request->getParameter($form->getName()), $request- >getFiles($form->getName())); if ($form->isValid()) { $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.'; $facility = $form->save(); $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $facility))); if ($request->hasParameter('_save_and_add')) { $this->getUser()->setFlash('notice', $notice.' You can add another one below.'); $this->redirect('@facility_new'); } else { $this->getUser()->setFlash('notice', $notice); $this->redirect(array('sf_route' => 'facility_edit', 'sf_subject' => $facility)); } } else { $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false); } } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---