Active
Project:
Ubercart Dependent Attributes
Version:
6.x-1.x-dev
Component:
User interface
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
30 May 2011 at 18:17 UTC
Updated:
31 May 2011 at 11:34 UTC
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
Comment #1
Oleg_url commentedComment #2
Oleg_url commentedI 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,
----------------------------------------------------------------------------------------------------------------------