function panels_common_edit_argument_form in Panels 5.2
Same name and namespace in other branches
- 6.2 includes/common-context.inc \panels_common_edit_argument_form()
Form (for ajax use) to add an argument
File
- includes/
common.inc, line 1319 - Functions used by more than one panels client module.
Code
function panels_common_edit_argument_form($panel_page, $argument, $position) {
// Basic values required to orient ourselves
$arg = $panel_page->arguments[$position];
$form['position'] = array(
'#type' => 'hidden',
'#value' => $position,
);
$form['start_form'] = array(
'#value' => '<div class="modal-form">',
);
$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']['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.'),
),
'#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 by the administrator.'),
);
$form['argument']['id'] = array(
'#type' => 'value',
'#value' => $arg['id'],
);
$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'];
}
$form['arg'] = array(
'#type' => 'value',
'#value' => $argument,
);
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['end_form'] = array(
'#value' => '</div>',
);
$form['next'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}