Why does the following module function do nothing?

**
* Add a description to the Privacy attribute.
*/
function custom_site_form_uc_product_add_to_cart_form_6584_1_alter(&$form, &$form_state) {
  dpm( get_defined_vars() );
  $text = 'Some text.<br />';
  $text .= 'Some more text';
  $form['attributes'][19]['#prefix'] = t($text);
}

Comments

topdillon’s picture

Issue summary: View changes

hide organization

TR’s picture

Status: Active » Fixed

Title says syntax error, but you didn't mention anything about that ... Your code sample *is* missing a / before the initial **

I tried this using my own module, my own product nid, and my own attribute aid. It worked.

So the problem is either:
1) Because you named the function wrong ("_1" ? What's that? Is this function in a module called "custom_site"? Is the nid of your product really "6584"?), or
2) Because your module's alter function is being called *after* uc_attribute's alter function. If it's this second cause, just increase your module's weight in the system table (you can do that in hook_install()).

And you should upgrade to a more recent version of Ubercart before you start writing custom code - that will save you a lot of problems in the long run.

topdillon’s picture

Thanks TR.

It turns out the mysterious "_1" was not needed even though the form id, as read via Firebug, was "uc-product-add-to-cart-form-6584-1".

topdillon’s picture

Issue summary: View changes

continue to obliterate identity

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.