/** * Recurse the given form and return the descriptions for it and all of its subforms * * @param Form $form The form to recurse * * @return array */ protected function recurseForm(Form $form) { $descriptions = array($form->getDescriptions()); foreach ($form->getSubForms() as $subForm) { $descriptions[] = $this->recurseForm($subForm); } return call_user_func_array('array_merge', $descriptions); }
/** * Recurse the given form and return the notifications for it and all of its subforms * * @param Form $form The form to recurse * * @return array */ protected function recurseForm(Form $form) { $notifications = $form->getNotifications(); foreach ($form->getSubForms() as $subForm) { $notifications = $notifications + $this->recurseForm($subForm); } return $notifications; }
/** * Recurse the given form and return the notifications for it and all of its subforms * * @param Form $form The form to recurse * * @return array */ protected function recurseForm(Form $form) { $notifications = $form->getNotifications(); foreach ($form->getSubForms() as $subForm) { foreach ($this->recurseForm($subForm) as $type => $messages) { foreach ($messages as $message) { $notifications[$type][] = $message; } } } return $notifications; }
/** * Recurse the given form and return the descriptions for it and all of its subforms * * @param Form $form The form to recurse * @param mixed $entirelyRequired Set by reference, true means all elements in the hierarchy are * required, false only a partial subset and null none at all * @param bool $elementsPassed Whether there were any elements passed during the recursion until now * * @return array */ protected function recurseForm(Form $form, &$entirelyRequired = null, $elementsPassed = false) { $requiredLabels = array(); if ($form->getRequiredCue() !== null) { $partiallyRequired = $partiallyOptional = false; foreach ($form->getElements() as $element) { if (!in_array($element->getType(), $this->blacklist)) { if (!$element->isRequired()) { $partiallyOptional = true; if ($entirelyRequired) { $entirelyRequired = false; } } else { $partiallyRequired = true; if (($label = $element->getDecorator('label')) !== false) { $requiredLabels[] = $label; } } } } if (!$elementsPassed) { $elementsPassed = $partiallyRequired || $partiallyOptional; if ($entirelyRequired === null && $partiallyRequired) { $entirelyRequired = !$partiallyOptional; } } elseif ($entirelyRequired === null && $partiallyRequired) { $entirelyRequired = false; } } $descriptions = array($form->getDescriptions()); foreach ($form->getSubForms() as $subForm) { $descriptions[] = $this->recurseForm($subForm, $entirelyRequired, $elementsPassed); } if ($entirelyRequired) { foreach ($requiredLabels as $label) { $label->setRequiredSuffix(''); } } return call_user_func_array('array_merge', $descriptions); }