Sometimes you need to validate a specific data using a form validator.
Instead of binding the entire form, let’s just use the existing validator of the field we want to update :
try { $product = ProductPeer::retrieveByPk($request->getParameter(‘id‘); $this->form = new sfProductForm($product); $validators = $this->form->getValidatorSchema(); // Get the validator for the ‘name’ field and clean/validate input $clean_name = $validators['name']->clean($request->getParameter(‘name‘); echo ’ok‘; } catch (sfValidatorError $e) { $e->getMessage(); }
No Comments Yet