Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #0.0
topdillon CreditAttribution: topdillon commentedhide organization
Comment #1
TR CreditAttribution: TR commentedTitle 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.
Comment #2
topdillon CreditAttribution: topdillon commentedThanks 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".
Comment #2.0
topdillon CreditAttribution: topdillon commentedcontinue to obliterate identity