Symfony\Component\Form\Form::count PHP Method

count() public method

Returns the number of form children (implements the \Countable interface).
public count ( ) : integer
return integer The number of embedded form children
    public function count()
    {
        return count($this->children);
    }

Usage Example

Example #1
0
 public function getFormErrorMessages(\Symfony\Component\Form\Form $form)
 {
     $errors = array();
     $formErrors = iterator_to_array($form->getErrors(false, true));
     foreach ($formErrors as $key => $error) {
         $template = $error->getMessageTemplate();
         $parameters = $error->getMessageParameters();
         foreach ($parameters as $var => $value) {
             $template = str_replace($var, $value, $template);
         }
         $errors[$key] = $template;
     }
     if ($form->count()) {
         foreach ($form as $child) {
             if (!$child->isValid()) {
                 $errors[$child->getName()] = $this->getFormErrorMessages($child);
             }
         }
     }
     return $errors;
 }
All Usage Examples Of Symfony\Component\Form\Form::count