You are here

function civicrm_entity_discount_field_form_field_ui_field_overview_form_alter in CiviCRM Entity 7.2

Implements hook_form_FORMID_alter().

form id : field_ui_field_overview_form

Only allow creation of civicrm_entity_discount_fields to civicrm_event entity type

_state

Parameters

$form:

File

modules/civicrm_entity_discount/civicrm_entity_discount_field.module, line 107
Provide CiviCRM Entity Discount Field Type. Provides a widget for selecting custom discount options

Code

function civicrm_entity_discount_field_form_field_ui_field_overview_form_alter(&$form, &$form_state) {
  if ($form['#entity_type'] != 'civicrm_event') {
    unset($form['fields']['_add_new_field']['type']['#options']['civicrm_entity_discount_field']);
    foreach ($form['fields']['_add_existing_field']['field_name']['#options'] as $field_name => $description) {
      if (strpos($description, 'CiviCRM Entity Discount Settings') !== FALSE) {
        unset($form['fields']['_add_existing_field']['field_name']['#options'][$field_name]);
      }
    }
  }
}