Hello. I have lots of options attributes. The page displays 20 items adyustments dependencies. It would be nice to add a checkbox to enable / disable 20 items at once.
I think I need to insert a small piecewise code.
Very thanks for the idea.

Comments

Oleg_url’s picture

Title: Enabled / Disabled options for the 20 attributes » Enabled / Disabled dependencies for the 20 attributes
Oleg_url’s picture

I think here you need to add the condition.
--------------------------------------------------------------------------------------------------
function uc_dependent_attributes_form_alter(&$form, $form_state, $form_id) {
// Add an enabled checkbox to the product adjustments form
if ($form_id == 'uc_product_adjustments_form') {
// Retrieve disabled combinations from the database
$result = db_query("SELECT combination FROM {uc_dependent_attributes} WHERE nid = %d", $form['nid']['#value']);
$combos = array();
while ($combo = db_result($result)) {
$combos[] = $combo;
}

// Update the table header
$form['table']['head']['#value'] = 'Enabled'. $form['table']['head']['#value'];

// Loop through each form element adding an enabled checkbox
foreach (element_children($form['table']['body']) as $key) {
$form['table']['body'][$key]['enabled'] = array(
'#type' => 'checkbox',
'#default_value' => !in_array($form['table']['body'][$key]['combo_array']['#value'], $combos),
'#prefix' => '',
'#suffix' => '',
'#weight' => -1,
----------------------------------------------------------------------------------------------------------------------