On Fri, Jun 27, 2008 at 10:57 AM, obalais <[EMAIL PROTECTED]> wrote:

> But i don't know how i can use the new form framework to validate the
> ajax form submission and return errors msgs or a success update to the
> template...

In your ajax action, you can just bind the values to your sfForm
instance and return the result of the isValid() method, or maybe a
json array containing the errors. Something like this :

public function executeValidate(sfWebRequest $request)
{
  $this->forward404Unless($request->isMethod('post'));
  $form = new sfPlanetFeedUrlForm();
  $form->bind($request->getParameter('params'));
  $errors = array();
  foreach ($form->getErrorSchema()->getErrors() as $field => $error)
  {
    $errors[$field] = $error->getMessage();
  }
  $this->getResponse()->setContentType('application/json');
  return $this->renderText(json_encode($errors));
}

HTH

++

-- 
Nicolas Perriault
http://prendreuncafe.com - http://symfonians.net - http://sensiolabs.com
Phone: +33 660 92 08 76

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to