button changes to disabled

button changes to disabled

le Daniele Cordella -
Number of replies: 6
Dealbh dhe Core developers Dealbh dhe Particularly helpful Moodlers Dealbh dhe Plugin developers

Hello.

May I ask why, in the attached all-in-one example, the procedure to export 'multiplication table' to excel changes the mform button status to disabled.

Thanks in advance.


(to execute the code, copy the file to your moodle test site wwwroot and visit moodle/test_form.php)


Average of ratings: -
In reply to Daniele Cordella

Re: button changes to disabled

le Andreas Grabs -
Dealbh dhe Core developers Dealbh dhe Particularly helpful Moodlers Dealbh dhe Peer reviewers Dealbh dhe Plugin developers Dealbh dhe Translators

Hi Daniele,

I am not that sure but it seems it has to do with the default behaviour of the submit buttons. They all are set to disabled on the submit event. And while the page is not reloaded but instead the download is started, all js actions are stopped and the disabled attribute is not removed.

Try that:

In your line 57 change

$mform = new test_form(new moodle_url('/test_form.php'));

To

$mform = new test_form(new moodle_url('/test_form.php'), null, 'post', '_blank');

After that, the button is enabled after the click.

Best regards
Andreas

Average of ratings: Useful (1)
In reply to Andreas Grabs

Ri: Re: button changes to disabled

le Daniele Cordella -
Dealbh dhe Core developers Dealbh dhe Particularly helpful Moodlers Dealbh dhe Plugin developers
Thanks Andreas for your WORKING solution.
I also did some more investigations
and I found that the issue may be deeper because...

using my newly attached test file I found that
- if I download to excel the button gets disabled
but
- if I download to csv the button status does not change.

mmmmhhhhhhh
In reply to Daniele Cordella

Re: Ri: Re: button changes to disabled

le Andreas Grabs -
Dealbh dhe Core developers Dealbh dhe Particularly helpful Moodlers Dealbh dhe Peer reviewers Dealbh dhe Plugin developers Dealbh dhe Translators

Hi Danielle,

that really is strange. Maybe there are different headers while sending the output and one header makes the browser stop the js execution.

Best regards Andreas

In reply to Andreas Grabs

Re: button changes to disabled

le Tim Hunt -
Dealbh dhe Core developers Dealbh dhe Documentation writers Dealbh dhe Particularly helpful Moodlers Dealbh dhe Peer reviewers Dealbh dhe Plugin developers
Moodle forms have protection, to stop them being submitted twice if the button is double-clicked. See MDL-38555. What you are seeing is probably a side-effect of that.
In reply to Daniele Cordella

button changes to disabled

le Paul Holden -
Dealbh dhe Core developers Dealbh dhe Moodle HQ Dealbh dhe Moodle Workplace team Dealbh dhe Particularly helpful Moodlers Dealbh dhe Peer reviewers Dealbh dhe Plugin developers Dealbh dhe Testers
Hi Danielle, you can disable the double form submit protection easily - see same solution in MDL-71837
In reply to Paul Holden

Ri: button changes to disabled

le Daniele Cordella -
Dealbh dhe Core developers Dealbh dhe Particularly helpful Moodlers Dealbh dhe Plugin developers
Fantastic!
Thank you Andreas, Tim and Paul.
I found a solution in
https://integration.moodle.org/job/Precheck%20remote%20branch/108349/artifact/work/patchset.diff
and it works like a charm.

In spite of this my doubt is still alive: why do I get a form protection side effect if I download to xls and I DO NOT GET any side effect when downloading to csv?