When a user fills out a form and presses submit, the form is disabled while the information is submitted. I use the following code to disable the form:   $form.find('button').prop('disabled', true);   How can I replace the text of the button with a loading image?
121420
I have put together the following mootools script   window.addEvent('domready', function() {     var shouts = "timed.php";     var log = $('log_res');     function updateData (url,target)     {         new Ajax(url,{         method: 'get',          update: $(target),          onComplete: function() {         log.removeClass('ajax-loading');}  }).request();         log.empty().addClass('ajax-loading');     }      var update = function(){ updateData ( shouts, 'log_res' ); };     update();           // call it immediately     update.periodical(10000);   // and then periodically   });   heres the html  &lt;div id="AJAX"&gt;     &lt;h3&gt;Ajax Response&lt;/h3&gt;     &lt;div id="log_res"&gt;exercise&lt;/div&gt; &lt;/div&gt;   its using moo 1.1.  The above works fine, the page loads then the ajax request kicks in div id log_res has a class of ajax-loading whilst its updating, and when its finished the text exercise in the div is replaced with whatever the ajax has returned (yippee). But I want to put some custom HTML into the div WHILST the page is loading, because the ajax-loading class is not enough to contain the information, i also want to put a spinny flasher into the div whilst the ajax request is retrieving the information. Hope that makes sense!
1380
The property 'string' is protected as I can see here   but I need to change word "- Any -" in my exposed filter form to my string "All terms"?  I cannot do this cause I do not know how to use this class and how to change output.  This hook says: cannot get value of protected property.  function MYtheme_form_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {   if ( ( $form['#attributes']['class'][0] == 'views-exposed-form' ) &amp;&amp;          ( $form['#info']['filter-field_color_target_id']['operator'] == 'field_color_target_id_op' ) )   {       dpm($form['color']['#options']['All']-&gt;string);       //$form['color']['#options']['All']-&gt;string = t('All terms');   } }
29087
/**  * Implements hook_form_alter().  */ function MODULE_NAME_form_alter(   &amp;$form,   \Drupal\Core\Form\FormStateInterface $form_state,   $form_id ) {    if ($form_id == 'node_article_form') {     $form["body"]["widget"][0]['#allowed_formats'] = ['full_html']; // Your default format     $form["body"]["widget"][0]['#after_build'][] = 'MODULE_NAME_hide_format';   } }  function MODULE_NAME_hide_format(   &amp;$element,   FormStateInterface $form_state ) {   if (isset($element["format"]["format"])) {     $element["format"]["format"]["#access"] = FALSE;   }    return $element; }
19087
I thought they could be, but as I'm not putting my money where my mouth was (so to speak) setting the readonly attribute doesn't actually seem to do anything.  I'd rather not use Disabled, since I want the checked check boxes to be submitted with the rest of the form, I just don't want the client to be able to change them under certain circumstances.
18181
I've noticed this twice in the last ~2 weeks or so. The &quot;post your question&quot; button can remain disabled for some reason even when your question is shown as &quot;ready to publish&quot;. I.e., you've gotten to the &quot;review&quot; page after the initial edit. If I remember correctly, one case was on Stack Overflow, and the other was on . I'm not sure what exact scenario leads up to this. I haven't paid attention to the button until the last step when I'm ready to click it. The workaround has been to reload the page. (I copied my content for safe-keeping first.) This works, and the button then shows up as active. Afterwards, however, on both occasions, it forced me through the &quot;are you a human&quot; verification.  Update - this question itself did not exhibit this, nor did it do the .  Update - I'm using Chrome on Windows and am not sure what version it was when this happened.  It has  installed, but there aren't any scripts for any Stack Exchange sites.  It has  installed.  The virus scanner on the PC I probably was using was
6335
I have situation here, where I want to lock all the fields and buttons on a quote__c (custom object) where the status of the quote is changed to 'Sent' so that nothing can be editable on the quote.  Any ideas how to do this?
29024
I have a custom content type to allow users to upload images.  I'm trying to keep the interface as simple as possible.  The content type contains a single image field.  This works, but some users don't understand that the image has been uploaded because they don't see it after selecting (to preview the upload, the upload button must be pressed).  Is there a way to skip/automatically press the upload button so that an image is shown immediately after a file is selected?  In other words, immediately after selecting a file, instead of the following picture (where the path is shown but hard to read in Firefox):    I'd like the preview display to be shown like this:
110229
What is the easiest way to change the Add to cart form button text to something custom? I want to change the text only on certain product types. How should I approach this?
117259
I have a form created by a custom module. Now I want to show an alert like ("Please fil the complete form before navigating otherwise lost all the data") if the user navigate to another page without filling all required fields.  How can I do so?
23177
I want to disable a specific JS script from a specific website without disabling the javascript completely. Is there a way to do that ?
18317
I'm running into a problem where a user can submit any form built by the Form API multiple times (fast clicking resulting in multiple requests).  I've put in the basic client side (javascript) solution of disabling the button, but I'm curious what the best approach to preventing this situation is on the server side.  Is there a recommended way to use Drupal's form token system to handle this?  Especially a global form solution (ie, adding a custom validator to every form using hook_form_alter()).  My approach so far has been something like this:  function mymodule_form_alter(&amp;$form, &amp;$form_state, $form_id) {   $form['#validate'][] = 'mymodule_form_validate'; }  function mymodule_form_validate(&amp;$form, &amp;$form_state){   //initialize form array   if (!isset($_SESSION['submitted_forms'])){     $_SESSION['submitted_forms'] = array();   }    $form_token = $form_state['values']['form_token'];   if ( isset($_SESSION['submitted_forms'][$form_token]) &amp;&amp; $_SESSION['submitted_forms'][$form_token] = TRUE ){     form_set_error('name]', 'This form has already been submitted');   }   else{     $_SESSION['submitted_forms'][$form_token] = TRUE;   } }   I'm running into trouble where the form_token isn't unique to the form - it seems to stay the same no matter what happens.  I'm probably misunderstanding what the token is in the grand scheme of the form api.  Any insight is appreciated!
17965
I need to prevent accidental clicks in the Save button when a node is being saved.  I found this   which does exactly this. But the problem is that it uses javascript (jquery). Then if the user disable javascript this module is useless.  My problem is that in my website the user get points when creating nodes, so I have to prevent this in a more secure way.  How can I do this?   What do you think of these ideas?:  1) Maybe I would forbid the node being saved more than one time    programmatically instead of disabling the Save button.   2) Or better: I would allow the user to just save a new node every 5 minutes.
108399
How to change the form label from Password to New Password and Confirm password to New Confirm password on THEME_form_user_form_alter(without changing any twig files)? I had tried kint($form['account']['pass']) to see any possible way, no clue...  Current Change Password Form  Current password  |||||||||||||||||  Password (to New Password)  |||||||||||||||||  Confirm password (to New Confirm password)  |||||||||||||||||  function THEME_form_user_form_alter(&amp;$form, $form_state) {   kint($form['account']); }   There are no #title element on pass field.
119645
Component  &lt;aura:component implements="force:lightningQuickAction"&gt;     &lt;ui:inputNumber aura:id="num1"/&gt; +     &lt;ui:inputNumber aura:id="num2"/&gt;     &lt;br/&gt;     &lt;ui:button label="Add" press="{!c.showToast}"/&gt; &lt;/aura:component&gt;   Controller    ({         showToast : function(component, event, helper) {         var n1 = component.find("num1").get("v.value");         var n2 = component.find("num2").get("v.value");          // Display the total in a "toast" status message          var resultsToast = $A.get("e.force:showToast");         resultsToast.setParams({             "title": "Quick Add: " + n1 + " + " + n2,             "message": "The total is: " + (n1 + n2) + "."         });         resultsToast.fire();          // Close the action panel          var dismissActionPanel = $A.get("e.force:closeQuickAction");         dismissActionPanel.fire();         }     })   ERROR MESSAGE     This page has an error. You might just need to refresh it. Action   failed: c$TestCheck1$controller$showToast [Cannot read property   'setParams' of undefined] Failing descriptor:   {c$TestCheck1$controller$showToast}
34262
How do you prevent an ENTER key press from submitting a form in a web-based application?
108897
I have created a checkbox in user edit using form alter and based checkbox state I want to print the message. For this I used below code  function module_form_user_profile_form_alter(&amp;$form, &amp;$form_state) {    $form['account']['checkbox'] = array(     '#type' =&gt; 'checkbox',     '#title' =&gt; 'Test check',    );    $form['#submit'][] = 'module_simplenews_unsubscribe'; }  //~ //Submit handler for Subscribe/unsubscribe newsletter. function module_simplenews_unsubscribe($form, &amp;$form_state) {    if ($form['account']['checkbox']['#value'] == 0) {     drupal_set_message(t("You are checked"));   }  if ($form['account']['checkbox']['#value'] == 1) {      drupal_set_message(t("You are unchecked"));   } }   It works fine. When checkbox is checked/unchecked and user saves the profile it prints respective message. But when user doesn't modify this checkbox field and modify some other field and saves, again it prints message based on checkbox state.  I want to display the message only when checkbox field is modified. How can I achieve this?
98751
In the moderator flags list, there is a &quot;Convert to Edit&quot; button on answers which are posted by the person who posted the question. This button is disabled at times, and I am not sure that the algorithm used is useful. My proposal is that the Convert to Edit button in the flag list should always be enabled, as it seems fairly frequent that it's disabled when it would be useful. Justification When the button is disabled, it is required that we pop open the answer view in the flag list, and use the regular Mod menu and choose convert to edit there. When we do that, however, we experience this issue:  (that should also be fixed, by the way!) Here are two items currently in the queue:    Note that one has the button enabled, while the other does not. The only differences I can see in those two answers is the age and the number of answers. Neither question has an accepted answer, but the one with the button disabled only has that single answer. I've only just now noticed that difference with these two posts, so I'm not 100% sure if that's the determining factor. 1 It is perhaps coincidental, but these buttons being (dis)abled are reverse of the action needing to be taken. The one with the disabled button needed to be converted to an edit; the one with the enabled button was an attempt to answer their own question. If I'm right about the determining factor here (that the answer is the only one), I'm not sure that's useful. A good bit of the time, an asker will post an answer due to people requesting additional information. In such cases, it seems like it will be likely there are no other answers. 1  Note 1: I was looking to create a userscript to enable these buttons, and I found something that I think is related as to the reason. It looks like the ones which are disabled are on answers which have comments on them. I noticed the title attribute of those buttons says, &quot;There are comments on the post. Please review&quot;. That does seem to make some sense in theory. However, it still seems like I am often converting them, anyway. With the above-linked, separate issue regarding how the 'mod' link on the expanded view works, this is still a bit of an impediment to our workflow. It occurred to me to check if the button was reenabled once you expanded the view, but it does not. Maybe that's an alternate solution. My plan for my userscript is to enable the button, but change the text color (and leave the title attribute), to point out that there are comments.