0

I need to render the HTML of the errors messages below the submit button for styling purpose. I find out about Inline Form Errors; however, this will display an error message after the field and not after the submit button.

Any idea how can achieve this?

1

Try form alter method you can add text like following:

 $form['some_text'] = array(
      '#markup' => '<p>Some text</p>'
    );

Hope it will help!!

  • This will help me to add new text above the button. However, what about the another message ? The another message still there. – darol100 Jan 13 '16 at 11:13
0

Webform is essentially a node. $message variable is rendered in page.tpl.php and it outputs all messages (errors, status, warnings). If you don't have anything else on the page but your form, and you don't mind outputting all kinds of messages that may appear on the page under your submit button, then - overriding page template for that one form might work.

You would create a page--node--nodeID.tpl.php. Move $message variable below $content variable. Clear cache. This is a quick but not a very elegant approach.

  • another option is to tweak Inline Form Errors module to fit your needs - that will take a bit longer. – oksana-c Jan 13 '16 at 11:51
0

There is other good way : You can check for the errors in the form and set error message to the submit button. See below code -

$errormsg = form_get_errors();
if (isset($errormsg['test_list'])) {
  $form['botcont']['submit']['#suffix'] = '<div class="messages error messages-inline">' . $errormsg['test_list'] . "</div>";
}else {
  $form['botcont']['submit']['#suffix'] = NULL;
}

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.