General developer forum

Replicating the noSubmitButton behaviour with a select element

 
Picture of David Poly
Re: Replicating the noSubmitButton behaviour with a select element
 

For anyone interested, I solved my problem with the select registred as a noSubmitButton. The problem was that it was always set, on every submit, even the ones coming from the save buttons. So all user submits were considered of the nosubmit type. Therefore it would never go through validation. So I attached a handler to disable the select on submit. I'm using a hidden input to keep track of all the changes.

Now it finally works as I intended.

Also,

this JS code:

window.onbeforeunload = function(e) {
    e.preventDefault();
    e.stopPropagation();
};


can be swapped with this PHP one:

$mform->disable_form_change_checker();


This was a special case because the module form looks very different in my project depending on the option selected. I feel there's a much simpler way of doing it but for now it'll do and I have a working noSubmit select. 

 
Average of ratings: -