You are here

function ctools_plugin_configure_form in Chaos Tool Suite (ctools) 7

Get a plugin configuration form.

The $form_info and $form_state need to be preconfigured with data you'll need such as whether or not you're using ajax, or the modal. $form_info will need your next/submit callbacks so that you can cache your data appropriately.

Parameters

array $form_info: This form_info *must* contain at least the path. next and finish callbacks are advisable but not necessary if using wizard's auto caching. Setting a cache mechanism is advisable. If not using auto caching, next and finish callbacks will be necessary.

Also be sure to set up things such as AJAX settings and any temporary data you will need. Simply setting 'modal' => TRUE and 'modal return' => TRUE should make this system work well in the modal.

In addition to standard wizard fields, this supports one extra field:

  • 'default form': A callback to a 'wrapper' that will be applied to either the first or a marked form. This is useful for adding global features that are applicable to all instances of a plugin, such as identifiers, or contexts, or the like.

array &$form_state: This is a standard form state array. This system imposes some requirements on what will be in the form state:

  • 'plugin': The plugin definition being edited.
  • 'conf': The configuration that is being edited, presumed to be an array. Ultimately at the end, this is where the modified config will be found.
  • 'op': The operation, either 'add' or 'edit'. This is used to derive form names and can also be used to derive default values from the plugin.
  • 'step': The current step. May be null if it is the 'first' step, but generally needs to be defined in the path.

string $default_form: An optional default form that can be added.

Return value

If this function returns false, no form exists.

2 calls to ctools_plugin_configure_form()
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
1 string reference to 'ctools_plugin_configure_form'
_ctools_plugin_configure_create_form_info in includes/plugins-admin.inc

File

includes/plugins-admin.inc, line 56
Contains generic plugin administration functions.

Code

function ctools_plugin_configure_form($form_info, &$form_state) {

  // Turn the forms defined in the plugin into the format the wizard needs.
  _ctools_plugin_configure_create_form_info($form_info, $form_state['plugin'], $form_state['op']);
  if (empty($form_info['order'])) {
    return FALSE;
  }
  ctools_include('wizard');
  return ctools_wizard_multistep_form($form_info, $form_state['step'], $form_state);
}