Return to Snippet

Revision: 18652
at October 6, 2009 03:06 by skwok


Initial Code
public function getErrors()
 {
   $errors = array();

   // individual widget errors
   foreach ($this as $form_field)
   {   
     if ($form_field->hasError())
     {   
       $error_obj = $form_field->getError();
       if ($error_obj instanceof sfValidatorErrorSchema)
       {   
         foreach ($error_obj->getErrors() as $error)
         {   
           // if a field has more than 1 error, it'll be over-written
           $errors[$form_field->getName()] = $error->getMessage();
         }   
       }   
       else
       {   
         $errors[$form_field->getName()] = $error_obj->getMessage();
       }   
     }   
   }   

   // global errors
   foreach ($this->getGlobalErrors() as $validator_error)
   {   
     $errors[] = $validator_error->getMessage();
   }   

   return $errors;
  }

Initial URL

                                

Initial Description
Add snippet in BaseFormPropel.class.php

Initial Title
Get all symfony form errors

Initial Tags
debug

Initial Language
PHP