2

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) {
unset($form['attributes']['field_size']['#ajax']['progress']['message']);
}

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.

4
  • 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, 2012 at 10:30
  • A display:none is always quick eheh but what if I would like to change it? How could I do it? Aug 7, 2012 at 10:42
  • @Clive No reason to use CSS on stuff that Drupal already have made configurable ;)
    – googletorp
    Aug 13, 2012 at 8:28
  • @googletorp Good point, I was just being lazy ;)
    – Clive
    Aug 13, 2012 at 8:41

2 Answers 2

4

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.

3
  • 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 Aug 13, 2012 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, 2012 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. Aug 13, 2012 at 10:52
1

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');
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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