function ctools_edit_context_form_defaults
Form wrapper for the edit context form.
@todo: We should uncombine these.
2 string references to 'ctools_edit_context_form_defaults'
- ctools_context_ajax_item_add in includes/
context-admin.inc - Ajax entry point to add an context
- ctools_context_ajax_item_edit in includes/
context-admin.inc - Ajax entry point to edit an item
File
-
includes/
context-admin.inc, line 683
Code
function ctools_edit_context_form_defaults($form, &$form_state) {
// Basic values required to orient ourselves
$object = $form_state['object'];
$plugin_definition = $form_state['plugin'];
$type_info = $form_state['type info'];
$contexts = $form_state['contexts'];
$conf = $form_state['conf'];
if ($type_info['key'] == 'arguments' && !isset($conf['default'])) {
$conf['default'] = 'ignore';
$conf['title'] = '';
}
$form['description'] = array(
'#prefix' => '<div class="description">',
'#suffix' => '</div>',
'#markup' => check_plain($plugin_definition['description']),
);
if ($type_info['key'] == 'relationships') {
$form['context'] = ctools_context_selector($contexts, $plugin_definition['required context'], isset($conf['context']) ? $conf['context'] : '');
}
if ($type_info['key'] == 'arguments') {
$form['default'] = array(
'#type' => 'select',
'#title' => t('Default'),
'#options' => array(
'ignore' => t('Ignore it; content that requires this context will not be available.'),
'404' => t('Display page not found or display nothing at all.'),
),
'#default_value' => $conf['default'],
'#description' => t('If the argument is missing or is not valid, select how this should behave.'),
);
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $conf['title'],
'#description' => t('Enter a title to use when this argument is present. You may use %KEYWORD substitution, where the keyword is specified below.'),
);
}
$form['identifier'] = array(
'#type' => 'textfield',
'#title' => t('Identifier'),
'#description' => t('Enter a name to identify this !type on administrative screens.', array(
'!type' => t('context'),
)),
'#default_value' => $conf['identifier'],
);
$form['keyword'] = array(
'#type' => 'textfield',
'#title' => t('Keyword'),
'#description' => t('Enter a keyword to use for substitution in titles.'),
'#default_value' => $conf['keyword'],
);
if ($type_info['key'] == 'requiredcontexts') {
$form['optional'] = array(
'#type' => 'checkbox',
'#title' => t('Context is optional'),
'#default_value' => !empty($form_state['conf']['optional']),
'#description' => t('This context need not be present for the component to function.'),
);
}
$form['#submit'][] = 'ctools_edit_context_form_defaults_submit';
return $form;
}