You are here

function commerce_customer_field_settings_form in Commerce Core 7

Implements hook_field_settings_form().

File

modules/customer/commerce_customer.module, line 768
Defines the customer profile entity and API functions to manage customers and interact with them.

Code

function commerce_customer_field_settings_form($field, $instance, $has_data) {
  $settings = $field['settings'];
  $form = array();
  if ($field['type'] == 'commerce_customer_profile_reference') {
    $options = array();

    // Build an options array of the customer profile types.
    foreach (commerce_customer_profile_type_get_name() as $type => $name) {
      $options[$type] = check_plain($name);
    }
    $form['profile_type'] = array(
      '#type' => 'radios',
      '#title' => t('Customer profile type that can be referenced'),
      '#options' => $options,
      '#default_value' => !empty($settings['profile_type']) ? $settings['profile_type'] : 'billing',
      '#disabled' => $has_data,
    );
    $form['options_list_limit'] = array(
      '#type' => 'textfield',
      '#title' => t('Options list limit'),
      '#description' => t('Limits the number of customer profiles available in field widgets with options lists; leave blank for no limit.'),
      '#default_value' => !empty($settings['options_list_limit']) ? $settings['options_list_limit'] : 50,
      '#element_validate' => array(
        'commerce_options_list_limit_validate',
      ),
    );
  }
  return $form;
}