Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6681921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:38:43+00:00 2026-05-26T04:38:43+00:00

When I submit the form without filling in one of the required fields( or

  • 0

When I submit the form without filling in one of the required fields( or any combination of required fields) there is no status message presented to let me know I have missed the required fields.
The second time I submit the form the status message shows me what fields are required.
The status message seems to be one step behind the form submission.

If after the first submit I change what fields are filled in and I submit again then the status message that should have show the previous time will show now.

When the form is filled in correctly it submits as normal.

The form is displayed using drupal_get_form( ‘otherWaysToRequest’ );
This is called in a template file in the theme.

Does anyone know why the status message is one step behind?

This is a sample of the code being used

function otherWaysToRequest(&$form_state)
{
    global $base_url;
    $pathToTheme = path_to_theme();

    $form['top-check'] = array(
        '#type'     => 'fieldset',
        '#attributes' => array('class' => 'checkboxes'),
    );

    $form['top-check']['gift'] = array(
        '#title'     => t('Included a gift'),
        '#type'      => 'checkbox',
        '#suffix'    => '<br />',
        '#required'  => false,
    );

    $form['top-check']['contact'] = array(
        '#title'     => t('I would like to speak to you'),
        '#type'      => 'checkbox',
        '#suffix'    => '<br />',
        '#required'  => false,
    );

    $form['name'] = array(
        '#title'     => t('Name'),
        '#type'      => 'textfield',
        '#required'  => true,
    );


    $form['email'] = array(
        '#title'     => t('Email Address'),
        '#type'      => 'textfield',
        '#required'  => true,
    );

    $form['bottom-check'] = array(
        '#type'     => 'fieldset',
        '#attributes' => array('class' => 'checkboxes'),
        '#description' => t('<p class="Items">If you have ...:</p><p class="Items">I have included .....</p>')
    );

    $form['bottom-check']['share'] = array(
        '#title'     => t('A Share'),
        '#type'      => 'checkbox',
        '#suffix'    => '<br />',
        '#required'  => FALSE,
    );

    $form['submit'] = array(
        '#type'         =>  'image_button',
        '#src'          =>  $pathToTheme.'/image.gif',
        '#value'        =>  t('Submit Form'),
    );
}

function otherWaysToRequest_validate($form, &$form_state)
{
    $mail_reg_ex     = '/[-a-zA-Z0-9._]+[@]{1}[-a-zA-Z0-9.]+[.]{1}[a-zA-Z]{2,4}/';

    if(!preg_match($mail_reg_ex, $form_state['values']['email']))
    {
        form_set_error('email', t('Invalid email address.'));
    }
    if( 0 == $form_state['values']['gift'] & 0 == $form_state['values']['contact'] )
    {
        form_set_error('gift', t('You must choose one of the first two options on the form'));
    }
}

function otherWaysToRequest_submit($form, &$form_state)
{
    //mail details
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:38:44+00:00Added an answer on May 26, 2026 at 4:38 am

    It’s because by the time you’re calling drupal_get_form in your template file the messages have already been committed for the current page; your validation messages will therefore show up the next time messages are displayed to the screen which is on the next page load.

    You should build up the form in a custom module rather than the theme to get around this. The easiest way would be to create a block which you can assign to a region (using either hook_block in Drupal 6 or a combination of hook_block_info() and hook_block_view in Drupal 7).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way I can make a dropdown submit a form without clicking
Any way to submit a form without refreshing the current page at all using
There is a way to automatically submit a form without clicking to a submit
Is there anyway I can submit a form without a submit button, but only
I want to submit a form without page refresh using jQuery. I found some
Here is my code. For some reason, if I submit the form without placing
I am trying to submit a form automatically without the need to press the
I'd like to submit data in a form, over HTTPS, without allowing the browser
I want to submit a form without using submit button how can i do
I'm trying to use form submit with jquery without a page refresh as demonstrated

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.