function ctools_context_add_item_to_form in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 includes/context-admin.inc \ctools_context_add_item_to_form()
Add a row to the form. Used both in the main form and by the ajax to add an item.
3 calls to ctools_context_add_item_to_form()
- ctools_context_add_item_table in includes/
context-admin.inc - Add the context table to the page.
- 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 334 - includes/common-context.inc Provide API for adding contexts for modules that embed displays.
Code
function ctools_context_add_item_to_form($module, $type, $name, &$form, $position, $item) {
// This is the single function way to load any plugin by variable type.
$info = ctools_context_data($type, $item['name']);
$form['title'] = array(
'#value' => check_plain($item['identifier']),
);
// Relationships not sortable.
$type_info = ctools_context_info($type);
if (!empty($type_info['sortable'])) {
$form['position'] = array(
'#type' => 'weight',
'#default_value' => $position,
'#attributes' => array(
'class' => 'drag-position',
),
);
}
$form['remove'] = array(
'#value' => ctools_ajax_image_button(ctools_image_path('icon-delete.png'), "ctools/context/ajax/delete/{$module}/{$type}/{$name}/{$position}", t('Remove this item.')),
);
$form['settings'] = array(
'#value' => ctools_modal_image_button(ctools_image_path('icon-configure.png'), "ctools/context/ajax/configure/{$module}/{$type}/{$name}/{$position}", t('Configure settings for this item.')),
);
}