You are here

function commerce_product_reference_form_field_ui_field_edit_form_alter in Commerce Core 7

Implements hook_form_FORM_ID_alter().

File

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

Code

function commerce_product_reference_form_field_ui_field_edit_form_alter(&$form, &$form_state) {

  // Alter the form if the user has selected to not display a widget for a
  // product reference field.
  if ($form['#instance']['widget']['type'] == 'commerce_product_reference_hidden') {

    // Add a help message to the top of the page.
    $form['hidden_product_reference_help'] = array(
      '#markup' => '<div class="messages status">' . t('This field has been configured to not display a widget. There is no way to enter values for this field via the user interface, so you must have some alternate way of adding data to these fields. The settings for the field will still govern what type of products can be referenced and whether or not their fields will be rendered into the referencing entity on display.') . '</div>',
      '#weight' => -20,
    );

    // Hide options from the form that pertain to UI based data entry.
    $form['instance']['description']['#access'] = FALSE;
    $form['instance']['required']['#access'] = FALSE;
    $form['instance']['default_value_widget']['#access'] = FALSE;
  }
}