You are here

function uc_dropdown_attributes_clear_input in Dropdown Attributes 7

Same name and namespace in other branches
  1. 8 uc_dropdown_attributes.module \uc_dropdown_attributes_clear_input()

Clear inputs for attribute.

Parameters

array $form: Form array.

array $form_state: Form state array.

int $aid: Attribute ID.

1 call to uc_dropdown_attributes_clear_input()
_uc_dropdown_attributes_product_build in ./uc_dropdown_attributes.module
Form build for products.

File

./uc_dropdown_attributes.module, line 301
Show/hide attributes based on the values of other attributes.

Code

function uc_dropdown_attributes_clear_input(&$form, &$form_state, $aid) {
  switch ($form['attributes'][$aid]['#type']) {
    case 'checkboxes':
      if (isset($form_state['input']['attributes'])) {
        foreach ($form_state['input']['attributes'][$aid] as $oid => $value) {
          $form_state['input']['attributes'][$aid][$oid] = NULL;
        }
      }
      break;
    case 'radios':
      $form_state['input']['attributes'][$aid] = NULL;
      break;
    case 'select':
      if ($form['attributes'][$aid]['#value'] != '') {
        $form['attributes'][$aid]['#value'] = '';
      }
      break;
    case 'textfield':
      $form_state['input']['attributes'][$aid] = '';
      break;
    default:
      break;
  }
}