You are here

function ctools_edit_argument_form in Chaos Tool Suite (ctools) 6

Form (for ajax use) to add an argument

1 string reference to 'ctools_edit_argument_form'
ctools_context_info in includes/context-admin.inc
Provide a list of the ways contexts can be embedded.

File

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

Code

function ctools_edit_argument_form(&$form_state) {

  // Basic values required to orient ourselves
  $object = $form_state['object'];
  $argument = $form_state['info'];
  $position = $form_state['position'];
  $contexts = $form_state['contexts'];
  $arg = $object->arguments[$position];
  if (!isset($arg['default'])) {
    $arg['default'] = 'ignore';
    $arg['title'] = '';
  }
  $form['description'] = array(
    '#prefix' => '<div class="description">',
    '#suffix' => '</div>',
    '#value' => check_plain($argument['description']),
  );

  // Basic argument values
  $form['argument']['#tree'] = TRUE;
  $form['argument']['name'] = array(
    '#type' => 'hidden',
    '#value' => $argument['name'],
  );
  $form['argument']['id'] = array(
    '#type' => 'hidden',
    '#value' => $arg['id'],
  );
  $form['argument']['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' => $arg['default'],
    '#description' => t('If the argument is missing or is not valid, select how this should behave.'),
  );
  $form['argument']['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#default_value' => $arg['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['argument']['identifier'] = array(
    '#type' => 'textfield',
    '#title' => t('Identifier'),
    '#description' => t('Enter a name to identify this !type on administrative screens.', array(
      '!type' => t('argument'),
    )),
    '#default_value' => $arg['identifier'],
  );
  $form['argument']['keyword'] = array(
    '#type' => 'textfield',
    '#title' => t('Keyword'),
    '#description' => t('Enter a keyword to use for substitution in titles.'),
    '#default_value' => $arg['keyword'],
  );

  // Settings particular to this argument
  $argument_settings = array();
  if (isset($arg['argument_settings'])) {
    $argument_settings = $arg['argument_settings'];
  }
  if (isset($argument['settings form']) && function_exists($argument['settings form'])) {
    $form['argument']['argument_settings'] = $argument['settings form']($argument_settings);
  }
  $form['argument']['argument_settings']['#tree'] = TRUE;
  $form['next'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}