/** * notices * Render notices for each individual field that has errors. * * @param string $form_id The form id. * @param bool $fetch Whether to return the notice or render it. * * @access public * @static * @since 1.0 */ public static function notices($form_id = null, $fetch = false) { if (!self::$form_submission) { return; } $submitted_form_id = piklist_form::get('form_id'); $errors = array(); foreach (self::$form_submission as $scope => $fields) { foreach ($fields as $field) { if ($field['errors']) { foreach ($field['errors'] as $error_messages) { $errors = array_merge($errors, $error_messages); } } } } $errors = array_unique($errors); if (($submitted_form_id && $form_id == $submitted_form_id || !$submitted_form_id) && !empty($errors) || $fetch) { $rendered_errors = array(); $content = '<ul>'; foreach ($errors as $error) { $content .= '<li>' . $error . '</li>'; } $content .= '</ul>'; $arguments = array('id' => 'piklist_validation_error', 'notice_type' => 'error', 'content' => $content); if ($fetch) { return piklist::render('shared/notice', $arguments, true); } else { piklist::render('shared/notice', $arguments); } } }