You are here

function commerce_coupon_handler_area_cart_form::options_form in Commerce Coupon 7

Same name and namespace in other branches
  1. 7.2 includes/views/handlers/commerce_coupon_handler_area_cart_form.inc \commerce_coupon_handler_area_cart_form::options_form()

Options form.

Overrides views_handler_area::options_form

File

includes/views/handlers/commerce_coupon_handler_area_cart_form.inc, line 71
Displays a commerce coupon form field item on cart's form:

Class

commerce_coupon_handler_area_cart_form
@file Displays a commerce coupon form field item on cart's form:

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  unset($form['empty']);

  // Build an options array of Views available for the cart contents pane.
  $options = array();

  // Generate an option list from all user defined and module defined views.
  foreach (views_get_all_views() as $view_id => $view_value) {

    // Only include line item Views.
    if ($view_value->base_table == 'commerce_coupon') {
      foreach ($view_value->display as $display_id => $display_value) {
        $options[check_plain($view_id)][$view_id . '|' . $display_id] = check_plain($display_value->display_title);
      }
    }
  }
  $form['cart_coupon_view'] = array(
    '#type' => 'select',
    '#title' => t('Coupon view to display'),
    '#description' => t('Specify the View to use under the cart. Select \'none\' to not display anything.'),
    '#options' => array(
      'none' => t('None'),
    ) + $options,
    '#default_value' => $this->options['cart_coupon_view'],
  );
  $form['weight'] = array(
    '#type' => 'textfield',
    '#title' => t('Form item weight'),
    '#description' => t('Sets the weight of the form so it\'s displayed at the bottom. Do not change this unless you have several forms in the same area'),
    '#default_value' => $this->options['weight'],
    '#required' => TRUE,
  );
}