function _entityreference_field_settings_process in Entity reference 7
Same name and namespace in other branches
- 8 entityreference.module \_entityreference_field_settings_process()
Callback for custom element processing.
1 string reference to '_entityreference_field_settings_process'
- entityreference_field_settings_form in ./
entityreference.module - Implements hook_field_settings_form().
File
- ./
entityreference.module, line 427 - Entityreference primary module file.
Code
function _entityreference_field_settings_process($form, $form_state) {
$field = isset($form_state['entityreference']['field']) ? $form_state['entityreference']['field'] : $form['#field'];
$instance = isset($form_state['entityreference']['instance']) ? $form_state['entityreference']['instance'] : $form['#instance'];
$has_data = $form['#has_data'];
$settings = $field['settings'];
$settings += array(
'handler' => 'base',
);
// Select the target entity type.
$entity_type_options = array();
foreach (entity_get_info() as $entity_type => $entity_info) {
$entity_type_options[$entity_type] = $entity_info['label'];
}
$form['target_type'] = array(
'#type' => 'select',
'#title' => t('Target type'),
'#options' => $entity_type_options,
'#default_value' => $field['settings']['target_type'],
'#required' => TRUE,
'#description' => t('The entity type that can be referenced through this field.'),
'#disabled' => $has_data,
'#size' => 1,
'#ajax' => TRUE,
'#limit_validation_errors' => array(),
);
ctools_include('plugins');
$handlers = ctools_get_plugins('entityreference', 'selection');
uasort($handlers, 'ctools_plugin_sort');
$handlers_options = array();
foreach ($handlers as $handler => $handler_info) {
$handlers_options[$handler] = check_plain($handler_info['title']);
}
$form['handler'] = array(
'#type' => 'fieldset',
'#title' => t('Entity selection'),
'#tree' => TRUE,
'#process' => array(
'_entityreference_form_process_merge_parent',
),
);
$form['handler']['handler'] = array(
'#type' => 'select',
'#title' => t('Mode'),
'#options' => $handlers_options,
'#default_value' => $settings['handler'],
'#required' => TRUE,
'#ajax' => TRUE,
'#limit_validation_errors' => array(),
);
$form['handler_submit'] = array(
'#type' => 'submit',
'#value' => t('Change handler'),
'#limit_validation_errors' => array(),
'#attributes' => array(
'class' => array(
'js-hide',
),
),
'#submit' => array(
'entityreference_settings_ajax_submit',
),
);
$form['handler']['handler_settings'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'entityreference-settings',
),
),
);
$handler = entityreference_get_selection_handler($field, $instance);
$form['handler']['handler_settings'] += $handler
->settingsForm($field, $instance);
_entityreference_get_behavior_elements($form, $field, $instance, 'field');
if (!empty($form['behaviors'])) {
$form['behaviors'] += array(
'#type' => 'fieldset',
'#title' => t('Additional behaviors'),
'#parents' => array_merge($form['#parents'], array(
'handler_settings',
'behaviors',
)),
);
}
return $form;
}