You are here

function panels_common_add_item_to_form in Panels 6.2

Same name and namespace in other branches
  1. 5.2 includes/common.inc \panels_common_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 panels_common_add_item_to_form()
panels_ajax_context_item_add in includes/common-context.inc
Ajax entry point to add an context
panels_ajax_context_item_edit in includes/common-context.inc
Ajax entry point to edit an item
panels_common_add_item_table in includes/common-context.inc
Add the context table to the page.

File

includes/common-context.inc, line 256
includes/common-context.inc Provide API for adding contexts for modules that embed displays.

Code

function panels_common_add_item_to_form($module, $type, $name, &$form, $position, $item) {
  panels_load_include('ajax');

  // This is the single function way to load any plugin by variable type.
  $info = panels_common_context_data($type, $item['name']);
  $form['title'] = array(
    '#value' => check_plain($item['identifier']),
  );

  // Relationships not sortable.
  $type_info = panels_common_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' => panels_ajax_image_button('icon-delete.png', "panels/ajax/context-delete/{$module}/{$type}/{$name}/{$position}", t('Remove this item.'), 'panels-no-modal'),
  );
  $form['settings'] = array(
    '#value' => panels_ajax_image_button('icon-configure.png', "panels/ajax/context-configure/{$module}/{$type}/{$name}/{$position}", t('Configure settings for this item.')),
  );
}