function 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 289

Code

function ctools_context_add_item_to_form($module, $type, $cache_key, &$form, $position, $item) {
    // This is the single function way to load any plugin by variable type.
    $info = ctools_context_get_plugin($type, $item['name']);
    $form['title'] = array(
        '#markup' => 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' => array(
                    'drag-position',
                ),
            ),
        );
    }
    $form['remove'] = array(
        '#markup' => ctools_ajax_image_button(ctools_image_path('icon-delete.png'), "ctools/context/ajax/delete/{$module}/{$type}/{$cache_key}/{$position}", t('Remove this item.')),
    );
    $form['settings'] = array(
        '#markup' => ctools_modal_image_button(ctools_image_path('icon-configure.png'), "ctools/context/ajax/configure/{$module}/{$type}/{$cache_key}/{$position}", t('Configure settings for this item.')),
    );
}