You are here

function civicrm_entity_price_set_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_price_set_field to civicrm_event or civicrm_contribution_page entity type

_state

Parameters

$form:

File

modules/civicrm_entity_price_set_field/civicrm_entity_price_set_field.module, line 148

Code

function civicrm_entity_price_set_field_form_field_ui_field_overview_form_alter(&$form, &$form_state) {
  if ($form['#entity_type'] != 'civicrm_event' && $form['#entity_type'] != 'civicrm_contribution_page') {
    unset($form['fields']['_add_new_field']['type']['#options']['civicrm_entity_price_set_field']);
    foreach ($form['fields']['_add_existing_field']['field_name']['#options'] as $field_name => $description) {
      if (strpos($description, 'CiviCRM Entity Price Set') !== FALSE) {
        unset($form['fields']['_add_existing_field']['field_name']['#options'][$field_name]);
      }
    }
  }
}