1

Im using D7 and Ubercart 3. But I think this is more a form question than anything else. When validating the checkout form I get a list of errors saying fields are required. And thats all fun and stuff, but I just want the error to say:

Please complete the form by filling out the highlighted fields.

And only once off course.

  • I think this will be of use to you: drupal.stackexchange.com/questions/12280/… – jdu Jul 5 '13 at 15:57
  • @jdu it does not i came across this post before. But this guys wants to change te message. I want to remove existing messages and replace all of them with one global message. – DD dev Jul 5 '13 at 15:59
  • I'll post as an answer to outline the process, but the functions to do it are explained in the above. – jdu Jul 5 '13 at 17:01
1

You'll want to use: theme_status_messages.

First, use drupal_get_messages to clear the queue.

Then, use drupal_set_message to add your new generic message.

0

Although @jdu solution will get you there, it seems like it will effect all messages rather than target this specific form. I would be inclined to use something a bit more specific:

Within template.php OR a custom module:

function themename_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'formid_form') {
    array_push($form['#validate'], 'custom_form_validation');
  }
}

function custom_form_validation($form, &$form_state) {
  if ($_SESSION['messages']['error']) {
    drupal_get_messages('error');
    drupal_set_message('Please review the form for errors', 'error');
  }
}
  • Hmm. I think I'd still want to find a solution that lets me know whether the form failed validation, and act upon that (rather than rely on $_SESSION). That being said, I'm not sure it exists out of the box with Drupal. You'd have to replace the default form validation from $form['#validate'] (as opposed to pushing onto it) and run your own validation with drupal_validate_form() – Chris Rockwell Jul 5 '13 at 18:57
0

By default the common validation messages is provided by IFE module.

Other alternative could be to use Field validation and its form validation rules (Required field rule). Alternatively check Rules module with the relevant condition/action rules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.