function synonyms_settings_form in Synonyms 7
Synonyms settings form for a specific entity type and bundle name.
Parameters
string $entity_type: Entity type for which to generate synonyms settings form
string $bundle: Bundle name for which to generate synonyms settings form
1 string reference to 'synonyms_settings_form'
- synonyms_menu in ./
synonyms.module - Implements hook_menu().
File
- ./
synonyms.pages.inc, line 462 - Menu page callbacks of Synonyms module.
Code
function synonyms_settings_form($form, &$form_state, $entity_type, $bundle) {
$form['settings'] = array(
'#tree' => TRUE,
'#theme' => 'synonyms_behaviors_settings',
'#id' => 'synonyms-behaviors-settings-wrapper',
'#entity_type' => $entity_type,
'#bundle' => $bundle,
);
$behaviors = synonyms_behaviors();
foreach ($behaviors as $behavior => $behavior_info) {
$form['settings'][$behavior] = array(
'#title' => $behavior_info['title'],
);
$behavior_implementations = synonyms_behavior_get($behavior, $entity_type, $bundle);
foreach ($behavior_implementations as $implementation) {
$form['settings'][$behavior][$implementation['provider']]['#title'] = $implementation['label'];
if (isset($form_state['values']['settings'][$behavior][$implementation['provider']])) {
$behavior_settings = (bool) $form_state['values']['settings'][$behavior][$implementation['provider']]['enabled'];
}
else {
$behavior_settings = isset($implementation['settings']);
}
if ($behavior_settings) {
if (isset($form_state['values']['settings'][$behavior][$implementation['provider']]['settings'])) {
$behavior_settings = $form_state['values']['settings'][$behavior][$implementation['provider']]['settings'];
}
elseif (isset($implementation['settings'])) {
$behavior_settings = $implementation['settings'];
}
else {
$behavior_settings = array();
}
}
$form['settings'][$behavior][$implementation['provider']]['enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enable'),
'#default_value' => $behavior_settings !== FALSE,
);
$settings_form = ctools_plugin_get_function($behavior_info, 'settings form callback');
if ($settings_form) {
$form['settings'][$behavior][$implementation['provider']]['enabled']['#ajax'] = array(
'callback' => 'synonyms_settings_form_ajax',
'wrapper' => $form['settings']['#id'],
);
if ($behavior_settings !== FALSE) {
$form['settings'][$behavior][$implementation['provider']]['settings'] = $settings_form($form, $form_state, $behavior_settings);
}
}
}
}
$form['actions'] = array(
'#type' => '#actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}