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

  • Home
  • SEARCH
  • 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 7872145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:07:25+00:00 2026-06-03T02:07:25+00:00

I have a simple Drupal form in a custom module where exiting a textfield

  • 0

I have a simple Drupal form in a custom module where exiting a textfield should retrieve some information about the entered text via ahah to populate a div.

This works fine, except if the user quickly submits the form while the textfield’s ahah event is being processed.

It looks like while the ahah event is being processed the textfield is disabled, which of course means it’s value is not submitted. This means validation fails as the textfield is a required field, so the user is returned to the form with an appropriate error. The textfield is always empty when this happens.

If the user waits for the event to finish, the textfield returns to being enabled and submitting works as expected, as does submitting by using the enter key while in the textfield (the event doesn’t fire then, so the textfield isn’t disabled while it retrieves data).

Is there a way to disable the disabling of the textfield while it’s ahah event is being processed, or some other workaround?

Example of the textfield:

$form['id'] = array(
    '#type' => 'textfield',
    '#title' => t('Crop No.'),
    '#default_value' => $crop['id'] ? $crop['id'] : '',
    '#size' => 6,
    '#disabled' => $disabled,
    '#ahah' => array(
        'path' => 'spcs-myspuds/yields/js/crop/description/' . $crop_idx,
        'wrapper' => 'spcs-myspuds-yields-edit-crop-description-row-' . $crop_idx,
        'effect' => 'fade',
        'progress' => array(
            'type' => 'none',
        ),
    ),
);

Thanks in advance for any help.

  • 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-06-03T02:07:28+00:00Added an answer on June 3, 2026 at 2:07 am

    I found a workaround.

    I had to override Drupal.ahah.prototype.beforeSubmit, the function that disables the input before the submit (well, duh!).

    I included the following JavaScript in my module (using drupal_add_js):

    $(document).ready(function() {
      if (typeof beforeSubmitOverride == 'undefined' || beforeSubmitOverride == false) {
        Drupal.ahah.prototype.beforeSubmit = function (form_values, element, options) {
          // Disable the element that received the change.
          // IMiJ: Unless it's a text input, otherwise we could submit while element is diabled and loose data.
          if ($(this.element).attr('type') != 'text') {
            $(this.element).addClass('progress-disabled').attr('disabled', true);
          }
    
          // Insert progressbar or throbber.
          if (this.progress.type == 'bar') {
            var progressBar = new Drupal.progressBar('ahah-progress-' + this.element.id, eval(this.progress.update_callback), this.progress.method, eval(this.progress.error_callback));
            if (this.progress.message) {
              progressBar.setProgress(-1, this.progress.message);
            }
            if (this.progress.url) {
              progressBar.startMonitoring(this.progress.url, this.progress.interval || 1500);
            }
            this.progress.element = $(progressBar.element).addClass('ahah-progress ahah-progress-bar');
            this.progress.object = progressBar;
            $(this.element).after(this.progress.element);
          }
          else if (this.progress.type == 'throbber') {
            this.progress.element = $('<div class="ahah-progress ahah-progress-throbber"><div class="throbber">&nbsp;</div></div>');
            if (this.progress.message) {
              $('.throbber', this.progress.element).after('<div class="message">' + this.progress.message + '</div>');
            }
            $(this.element).after(this.progress.element);
          }
        };
      };
      beforeSubmitOverride = true;
    });
    

    This is a copy of Drupal.ahah.prototype.beforeSubmit as defined in misc/ahah.js with one small change, wrapping the disabling of the input with an if statement to make sure we don’t disable text fields.

    This is wrapped in a few lines to ensure the re-defining of the prototype happens just once after the DOM is ready.

    It might be better to only stop the disabling of the input if a setting is passed such as “disable” => false, but the above worked for the one case in the one page for the one custom module I needed this fix.

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

Sidebar

Related Questions

I have a custom form implemented in a custom module in drupal 6. The
I'm developing a custom module for Drupal 6, that creates a simple form. My
I'm developing a simple custom Drupal Module for creating Quizz, and I need some
I’m using drupal to create some custom form that submit to a third party,
I have a form field in Drupal which I need some help with. The
I'm writing a Drupal module and have run into what should be a trivial
I have a simple module which will return a form , but now i
I have simple win service, that executes few tasks periodically. How should I pass
I have simple form. <form target=_blank action=somescript.php method=Post id=simpleForm> <input type=hidden name=url value=http://...> <input
I have simple HTML code with some JavaScript. It looks like: <html> <head> <script

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.