You are here

function commerce_product_bundle_field_formatter_settings_form in Commerce Product Bundle 7

Same name and namespace in other branches
  1. 7.2 commerce_product_bundle.module \commerce_product_bundle_field_formatter_settings_form()

Implements hook_field_formatter_settings_form().

File

./commerce_product_bundle.module, line 39
Allows the bundling of products in Drupal Commerce.

Code

function commerce_product_bundle_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'] + commerce_product_bundle_field_formatter_default_settings();
  $element = array();
  if ($display['type'] == 'commerce_bundle_product_add_to_cart_form') {
    $element['show_quantity'] = array(
      '#type' => 'checkbox',
      '#title' => t('Display a textfield quantity widget on the add to cart form for this bundle.'),
      '#default_value' => $settings['show_quantity'],
    );
    $element['default_quantity'] = array(
      '#type' => 'textfield',
      '#title' => t('Default quantity'),
      '#default_value' => $settings['default_quantity'] <= 0 ? 1 : $settings['default_quantity'],
      '#element_validate' => array(
        'commerce_cart_field_formatter_settings_form_quantity_validate',
      ),
      '#size' => 16,
    );
    $element['show_fieldset'] = array(
      '#type' => 'checkbox',
      '#title' => t('Display the options in a fieldset.'),
      '#default_value' => $settings['show_fieldset'],
    );
    $element['bundle_type'] = array(
      '#type' => 'select',
      '#title' => t('Defines how referenced products are handled.'),
      '#default_value' => $settings['bundle_type'],
      '#options' => array(
        'single' => 'Single Select Box',
        'multiple' => 'Multiple Select Box',
        'hidden' => 'Hidden, add all products',
      ),
    );
  }
  return $element;
}