I've got a product with different taxonomy like "S" "M" "L". When you change the size in the display product, it shows the ajax div "Please wait..." I've tried

function bartik_form_commerce_cart_add_to_cart_form_alter(&$form, &$form_state, $form_id) {

If I have a look at it with dms($form) I see attributes -> field_size -> #ajax -> callback(commerce_cart_add_to_cart_form_attributes_refresh)

There is not message. How can I get rid of it?

Thanks in advance.

  • 1
    Save yourself the headache of tracking down and overriding the JS responsible for adding the loader, and just hide it with CSS – Clive Aug 7 '12 at 10:30
  • A display:none is always quick eheh but what if I would like to change it? How could I do it? – Tyler Durden Aug 7 '12 at 10:42
  • @Clive No reason to use CSS on stuff that Drupal already have made configurable ;) – googletorp Aug 13 '12 at 8:28
  • @googletorp Good point, I was just being lazy ;) – Clive Aug 13 '12 at 8:41

A simple way could be to hide it with CSS, but what is displayed by Drupal is actually configurable. The throbber with the Please wait... message is the default behavior but you can change it to a number of things. What you need to look at is the #ajax['progress'] attribute.

Usually #ajax['progress'] is not set in the form, and Drupal will add the default throbber with the Please wait... message in the JavaScript that handle the ajax request. The solution it quite simple, all you need to do is to set it like this:

$form['element']['#ajax']['progress'] = array('type' => 'throbber');

It will kill the message and only show the throbber. There are a number of ways to configure what Drupal does to show the user progress - you can read all about it in the link above.

| improve this answer | |
  • do you mean like this? function bartik_form_commerce_cart_add_to_cart_form_alter(&$form, &$form_state, $form_id) { $form['element']['#ajax']['progress'] = array('type' => 'throbber'); }, it does not work :( the hook is right because i'm testing it with $form['submit']['#attributes']['title'] = $form['submit']['#attributes']['value'] = t(''); and it empty the submit button – Tyler Durden Aug 13 '12 at 8:58
  • @SydBarrett The above code is example code - element should be replaced with the name of the element that has the #ajax property. – googletorp Aug 13 '12 at 10:50
  • Hey man, it works, I've changed ['element'] with ['attribute']['name_of_my_field'] . Now I can override it as I want. Thanks. – Tyler Durden Aug 13 '12 at 10:52

Thanks, but in comment mistake: not 'attribute' - 'attributes'.

function bartik_form_commerce_cart_add_to_cart_form_alter(&$form, &$form_state, $form_id) {
  $form['attributes']['field_NAME']['#ajax']['progress'] = array('type' => 'throbber');
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.