You are here

function commerce_product_reference_field_instance_settings_form in Commerce Core 7

Implements hook_field_instance_settings_form().

File

modules/product_reference/commerce_product_reference.module, line 597
Defines a field type for referencing products from other entities.

Code

function commerce_product_reference_field_instance_settings_form($field, $instance) {
  $settings = $instance['settings'];
  $form = array();
  $form['field_injection'] = array(
    '#type' => 'checkbox',
    '#title' => t('Render fields from the referenced products when viewing this entity.'),
    '#description' => t('If enabled, the appearance of product fields on this entity is governed by the display settings for the fields on the product type.'),
    '#default_value' => isset($settings['field_injection']) ? $settings['field_injection'] : TRUE,
    '#weight' => -9,
  );

  // Build an options array of the product types.
  $options = array();
  foreach (commerce_product_type_get_name() as $type => $name) {
    $options[$type] = check_plain($name);
  }
  $form['referenceable_types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Product types that can be referenced'),
    '#description' => t('If no types are selected, any type of product may be referenced.'),
    '#options' => $options,
    '#default_value' => is_array($settings['referenceable_types']) ? $settings['referenceable_types'] : array(),
    '#multiple' => TRUE,
    '#weight' => -3,
  );
  return $form;
}