You are here

function civicrm_entity_profile_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_profile_fields to civicrm_event or civicrm_contribution_page entity types

_state

Parameters

$form:

File

modules/civicrm_entity_profile/civicrm_entity_profile.module, line 185

Code

function civicrm_entity_profile_form_field_ui_field_overview_form_alter(&$form, &$form_state) {
  $supported_entities = array(
    'civicrm_event',
    'civicrm_contribution_page',
  );
  if (!in_array($form['#entity_type'], $supported_entities)) {
    unset($form['fields']['_add_new_field']['type']['#options']['civicrm_entity_profile_field']);
    foreach ($form['fields']['_add_existing_field']['field_name']['#options'] as $field_name => $description) {
      if (strpos($description, 'CiviCRM Entity Profile') !== FALSE) {
        unset($form['fields']['_add_existing_field']['field_name']['#options'][$field_name]);
      }
    }
  }
}