function party_form_field_ui_field_overview_form_alter in Party 7
Implements hook_form_alter() for field_ui_field_overview_form().
Prevent the primary fields widget from being available to other entities.
File
- ./
party.module, line 1783 - Provides a generic CRM party entity.
Code
function party_form_field_ui_field_overview_form_alter(&$form, &$form_state) {
if ($form['#entity_type'] != 'party') {
$options = array();
// Get the normal select options.
foreach (array(
'_add_new_field',
'_add_existing_field',
) as $key) {
$options[] =& $form['fields'][$key]['widget_type']['#options'];
}
// Also get the JS settings options.
foreach ($form['#attached']['js'] as &$js) {
if (is_array($js) && isset($js['type']) && $js['type'] == 'setting') {
if (isset($js['data']['fieldWidgetTypes'])) {
$options[] =& $js['data']['fieldWidgetTypes'];
}
}
}
// Remove the primary field widget.
foreach ($options as &$option) {
foreach ($option as &$group) {
unset($group['party_primary_field']);
}
}
}
}