getChildren() public method

Returns all children in this group.
public getChildren ( ) : array
return array
Example #1
0
 public static function getAllErrors(Form $form, $parent_prefix = '')
 {
     $id = $parent_prefix . ($parent_prefix ? '_' : '') . $form->getName();
     $errors = array($id . '_errors' => array());
     foreach ($form->getErrors() as $error) {
         $errors[$id . '_errors'][] = array('error' => self::formatErrors($error));
     }
     if (!count($errors[$id . '_errors'])) {
         unset($errors[$id . '_errors']);
     }
     foreach ($form->getChildren() as $child) {
         if ($_errors = self::getAllErrors($child, $id)) {
             $errors = array_merge($errors, $_errors);
         }
     }
     if (count($errors)) {
         return $errors;
     } else {
         return false;
     }
 }
Example #2
0
 private function getErrorMessages(\Symfony\Component\Form\Form $form)
 {
     $errors = array();
     foreach ($form->getErrors() 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->hasChildren()) {
         foreach ($form->getChildren() as $child) {
             if (!$child->isValid()) {
                 $errors[$child->getName()] = $this->getErrorMessages($child);
             }
         }
     }
     return $errors;
 }
Example #3
0
 private function convertFormToArray(GenericSerializationVisitor $visitor, Form $data)
 {
     $isRoot = null === $visitor->getRoot();
     $form = $errors = array();
     foreach ($data->getErrors() as $error) {
         $errors[] = $this->getErrorMessage($error);
     }
     if ($errors) {
         $form['errors'] = $errors;
     }
     $children = array();
     foreach ($data->getChildren() as $child) {
         $children[$child->getName()] = $this->convertFormToArray($visitor, $child);
     }
     if ($children) {
         $form['children'] = $children;
     }
     if ($isRoot) {
         $visitor->setRoot($form);
     }
     return $form;
 }