You are here

function commerce_checkout_pane_settings_form in Commerce Core 7

Build the configuration form for a checkout pane.

1 string reference to 'commerce_checkout_pane_settings_form'
commerce_checkout_menu in modules/checkout/commerce_checkout.module
Implements hook_menu().

File

modules/checkout/includes/commerce_checkout.admin.inc, line 226
Administrative callbacks for the Checkout module.

Code

function commerce_checkout_pane_settings_form($form, &$form_state, $checkout_pane) {

  // Build the form array with the bare minimum fields.
  $form['checkout_pane'] = array(
    '#type' => 'value',
    '#value' => $checkout_pane,
  );
  $form['display'] = array(
    '#type' => 'fieldset',
    '#title' => t('Display settings'),
    '#description' => t('These settings are common to all checkout panes and affect their appearance on the checkout form.'),
  );
  $form['display']['collapsibility'] = array(
    '#type' => 'radios',
    '#title' => t('Checkout form fieldset display'),
    '#description' => t('Checkout panes are rendered on the checkout form in individual fieldsets.') . '<br />' . t('Specify here how the fieldset for this pane will appear.'),
    '#options' => array(
      'default' => t('Display this pane in a non-collapsible fieldset.'),
      'collapsible' => t('Display this pane in a collapsible fieldset.'),
      'collapsed' => t('Display this pane in a collapsed fieldset.'),
      'none' => t('Do not display this pane in a fieldset.'),
    ),
    '#default_value' => $checkout_pane['fieldset'] ? $checkout_pane['collapsible'] ? $checkout_pane['collapsed'] ? 'collapsed' : 'collapsible' : 'default' : 'none',
  );

  // If the checkout pane has a review callback, allow the user to include the
  // pane on the review checkout pane.
  $form['display']['review'] = array(
    '#type' => 'checkbox',
    '#title' => t('Include this pane on the Review checkout pane.'),
    '#default_value' => $checkout_pane['review'],
    '#access' => (bool) commerce_checkout_pane_callback($checkout_pane, 'review'),
  );

  // If a settings form exists for the specified checkout pane...
  if ($callback = commerce_checkout_pane_callback($checkout_pane, 'settings_form')) {

    // Create a fieldset to hold the checkout pane settings.
    $form['settings'] = array(
      '#type' => 'fieldset',
      '#title' => t('Checkout pane configuration'),
      '#description' => t('These settings are specific to this checkout pane.'),
    );

    // Add the settings from the callback to the form.
    $form['settings'] += $callback($checkout_pane);
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
    '#submit' => array(
      'commerce_checkout_pane_settings_form_save_submit',
    ),
  );
  $form['reset'] = array(
    '#type' => 'submit',
    '#value' => t('Reset to defaults'),
    '#suffix' => l(t('Cancel'), 'admin/commerce/config/checkout/form'),
    '#submit' => array(
      'commerce_checkout_pane_settings_form_reset_submit',
    ),
  );
  return $form;
}