You are here

function commerce_bpc_settings_form in Commerce Bulk Product Creation 7

Same name and namespace in other branches
  1. 7.2 commerce_bpc.settings.inc \commerce_bpc_settings_form()

BPC-specific wrapper for system_settings_form.

2 calls to commerce_bpc_settings_form()
commerce_bpc_display_node_settings_form in ./commerce_bpc.admin.inc
Form constructor for the commerce_bpc display node settings page.
commerce_bpc_pattern_settings_form in ./commerce_bpc.admin.inc
Form constructor for the commerce_bpc settings pages.

File

./commerce_bpc.admin.inc, line 261
Page generation callbacks the Commerce Bulk Product Creation settings pages.

Code

function commerce_bpc_settings_form($form, $settings_group, $product_type = NULL) {
  $form['settings_group'] = array(
    '#type' => 'value',
    '#value' => $settings_group,
  );
  if (!empty($product_type)) {
    $form['product_type'] = array(
      '#type' => 'value',
      '#value' => $product_type,
    );

    // For product-type specific forms, we add a checkbox for overriding,
    // and hide all form elements if it is unchecked.
    foreach ($form as $key => $element) {
      $form[$key]['#states']['visible'][':input[name="override"]'] = array(
        'checked' => TRUE,
      );
    }
    $types = commerce_product_types();
    $form['override'] = array(
      '#type' => 'checkbox',
      '#title' => t('Override settings for type %label', array(
        '%label' => $types[$product_type]['name'],
      )),
      '#default_value' => commerce_bpc_setting($settings_group, 'override', $product_type),
      '#weight' => -1,
    );
  }
  $form = system_settings_form($form);

  // Override the submit handler, so we can do pre- and suffixing.
  $form['#submit'] = array(
    'commerce_bpc_settings_form_submit',
  );
  return $form;
}