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 8338173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:30:35+00:00 2026-06-09T04:30:35+00:00

I got a form with only one field. This field is of the type

  • 0

I got a form with only one field. This field is of the type ‘managed_field’. When you click the “Upload” button a progress bar will show you the progress of the file upload. After that you will need to submit the form to save the file.

Since the progress bar won’t show up when you select a file and then click the form submit button instead of the “Upload” button. I would like to trigger a form submit after the upload (via the “Upload” button) has completed.

My current form looks like this:

$form['#attributes'] = array('enctype' => "multipart/form-data");

$form['pdf_upload'] = array(
    '#title' => t('Upload PDF'),
    '#type' => 'managed_file',
    '#required' => TRUE,
    '#progress_message' => t('Please wait...'),
    '#progress_indicator' => 'bar',
    '#upload_validators' => array(
        'file_validate_extensions' => array('pdf'),
    )

);

$form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
);

The file module handles the files via an ajax callback to the file/ajax/* uri. The callback returns ajax commands.

Basically i want to add an extra ajax command that triggers the form submit after the upload of the file has completed.

  • 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-09T04:30:36+00:00Added an answer on June 9, 2026 at 4:30 am

    @Clive That wasn’t an option for me since I wanted the users to start the upload themselves. You answer gave me some ideas though and I came up with the following solution.

    Drupal.behaviors.fileUpload = {
        attach: function(context, settings) {
            jQuery("body").ajaxComplete(function(event,request, settings){
                // Only do something when on the orders page of a user
                // This is where I use the upload functionality
                if(window.location.pathname.match(/user\/\d+\/orders/)) {
                    // Check if the AjaxComplete was triggered by the managed file upload
                    // pdf_upload_XXX is my form name
                    // Get the form-build-id from the URL
                    if (form_build_id = settings.url.match(/file\/ajax\/pdf_upload_\d*\/(.*)$/)) {
                        // Check if the upload has completed by checking if there is a Delete button in the form that has the form-build-id
                        if(jQuery('[value="'+form_build_id[1]+'"]').closest('form').find('[id$=remove-button]').length) {
                            // Click the submit button
                            jQuery('[value="'+form_build_id[1]+'"]').closest('form').find('[id^=edit-submit]').click();
                        }
                    }
                }   
            });
    
        }
    }
    

    Hope this is usefull for other users also.

    Thnx Clive for setting me on the right path.

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

Sidebar

Related Questions

I have a search form which contains only one text field with submit button.
I got this 2 array in a form to be process. However, i only
I've got a form which includes the option to upload an image. In my
i'm using this plug in to validate a form http://bassistance.de/jquery-plugins/jquery-plugin-validation/ I've got 3 fields,
I've got a form i want to apply validation to: <form id=calculator> <div class=f-field>
I've got a grid that only displays one piece of information such as a
I got a form in Django but when I use {{ form.as_p }} it
I have got a form into which information is entered, and a drop down
I've got a form inside a table that has some Javascript validation. The table
I've got a form that has to be a repeater on a webpage. I

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.