function multifield_form_field_ui_field_overview_form_alter in Multifield 7.2
Same name and namespace in other branches
- 7 multifield.module \multifield_form_field_ui_field_overview_form_alter()
Implements hook_form_FORM_ID_alter() for field_ui_field_overview_form().
File
- ./
multifield.module, line 500
Code
function multifield_form_field_ui_field_overview_form_alter(&$form, &$form_state) {
$multifields = array_intersect_key(multifield_get_fields(), array_flip($form['#fields']));
foreach ($multifields as $field_name => $machine_name) {
$subfields = multifield_type_get_subfields($machine_name);
if (!count($subfields)) {
$form['fields'][$field_name]['#attributes']['class'][] = 'warning';
$form['fields'][$field_name]['#attributes']['title'] = t('This multifield does not have any subfields yet.');
}
$form['fields'][$field_name]['type']['#suffix'] = ' | ' . l(t('Manage Subfields'), 'admin/structure/multifield/manage/' . $machine_name . '/fields', array(
'query' => drupal_get_destination(),
)) . '';
}
if ($form['#entity_type'] != 'multifield') {
return;
}
// Prevent multifields from being added to multifields themselves.
$form['fields']['_add_new_field']['type']['#options'] = array_diff_key($form['fields']['_add_new_field']['type']['#options'], module_invoke('multifield', 'field_info'));
if (isset($form['fields']['_add_existing_field'])) {
$form['fields']['_add_existing_field']['field_name']['#options'] = array_diff_key($form['fields']['_add_existing_field']['field_name']['#options'], multifield_get_fields());
}
// If this is a field attached to a multifield type that has instances, then
// preven changes being made to it so that it will not change field schema.
if (multifield_type_has_data($form['#bundle'])) {
drupal_set_message(t('Because the multifield already has data, some subfield settings can no longer be changed.'), 'warning');
//$form['fields']['_add_new_field']['#access'] = FALSE;
//$form['fields']['_add_existing_field']['#access'] = FALSE;
unset($form['fields']['_add_new_field']);
unset($form['fields']['_add_existing_field']);
unset($form['fields']['#regions']['add_new']);
foreach ($form['#fields'] as $field_name) {
$form['fields'][$field_name]['delete'] = array();
}
}
}