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.
I have a product where there are many colors available, but each product will only have one color. Currently, when you put up a new product, the admin has to deselect more than 20 checkboxes, which is rather cumbersome.
I want to stop the uc_attributes from selecting all of the Options on the ../edit/options page. I would like to do this correctly and use the hook_form_alter in a custom module--and avoid versioning problems in the future.
Can someone please help me out with the below code? I just need to get the if statement correct and this should work.
<?php
function mb_custom_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'uc_object_attributes_form') { /** THIS LINE NEEDS TO BE CORRECTED **/
$form["#submit"][] = 'mb_attribute_form_submit';
}
}
function mb_attribute_form_submit($form, &$form_state) {
if($form_state['values']['view'] == 'add') {
$attribute = uc_attribute_load($aid);
foreach ($attribute->options as $option) {
db_query("DELETE FROM {uc_product_options} WHERE nid = %d AND oid = %d", $form_state['values']['id'], $option->oid);
}
}
}
Comments
Comment #1
rszrama CreditAttribution: rszrama commentedIf I'm not mistaken, this may have been fixed already w/ a checkall box. : ?
Comment #2
colinjallen CreditAttribution: colinjallen commentedIt would be great if there was an preference pane to have Options either all checked or have none selected. I'm working on the lastest version of UC Attributes(6.x-2.0-rc3), and that's not the case.
Comment #3
Andy_Lowe CreditAttribution: Andy_Lowe commentedcleaning old / stale issues out of the queue
Comment #4
drifter CreditAttribution: drifter commentedThis is still active I'm afraid: having about 20 color options out of which only 2 or 3 will apply for a single product. Having to deselect all checkboxes is cumbersome. There is no 'check/uncheck all' option. Running Ubercart 2.2.
Comment #5
TR CreditAttribution: TR commented@drifter: On the options page at node/%/edit/options you'll see a checkbox in the header of the first column. That checkbox can be used to select or deselect all the options.
Comment #6
drifter CreditAttribution: drifter commentedMy bad, I was also using uc_option_image module, which has a bug that hides the 'select all' checkbox as well as the drag handles.