function page_manager_handler_add_form in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 page_manager/page_manager.admin.inc \page_manager_handler_add_form()
Provide a consistent UI for adding handlers.
2 calls to page_manager_handler_add_form()
- page_manager_handler_add in page_manager/
page_manager.admin.inc - Add a new task handler.
- page_manager_page_form_basic in page_manager/
plugins/ tasks/ page.admin.inc - Basic settings form for a page manager page.
File
- page_manager/
page_manager.admin.inc, line 1358 - Administrative functions for the page manager.
Code
function page_manager_handler_add_form(&$form, $form_state, $features = array()) {
$task = $form_state['task'];
$task_handler_plugins = page_manager_get_task_handler_plugins($task);
if (empty($task_handler_plugins)) {
drupal_set_message(t('There are currently no variants available and a page may not be added. Perhaps you need to install the Panels module to get a variant?'), 'error');
$form['buttons']['return']['#disabled'] = TRUE;
return;
}
foreach ($task_handler_plugins as $id => $plugin) {
$options[$id] = $plugin['title'];
if (isset($plugin['add features'])) {
$features[$id] = $plugin['add features'];
}
}
if (!isset($form_state['type']) || $form_state['type'] != 'add') {
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#description' => t('Administrative title of this variant. If you leave blank it will be automatically assigned.'),
);
}
$form['handler'] = array(
'#title' => t('Variant type'),
'#type' => 'select',
'#options' => $options,
);
// This set of checkboxes is not dangerous at all.
$form['features'] = array(
'#type' => 'checkboxes',
'#validated' => TRUE,
'#title' => t('Optional features'),
'#options' => array(),
'#description' => t('Check any optional features you need to be presented with forms for configuring them. If you do not check them here you will still be able to utilize these features once the new page is created. If you are not sure, leave these unchecked.'),
'#tree' => TRUE,
);
ctools_include('dependent');
foreach ($features as $plugin => $feature_list) {
foreach ($feature_list as $feature_id => $feature) {
$form['features'][$plugin][$feature_id] = array(
'#type' => 'checkbox',
'#title' => $feature,
);
if (!empty($form_state['page']->forms) && in_array($feature_id, $form_state['page']->forms)) {
$form['features'][$plugin][$feature_id]['#default_value'] = TRUE;
}
if ($plugin != 'default') {
$form['features'][$plugin][$feature_id] += array(
'#process' => array(
'ctools_dependent_process',
),
'#dependency' => array(
'edit-handler' => array(
$plugin,
),
),
);
}
}
}
}