function ctools_wizard_defaults in Chaos Tool Suite (ctools) 7
Same name and namespace in other branches
- 6 includes/wizard.inc \ctools_wizard_defaults()
Set default parameters and callbacks if none are given. Callbacks follows pattern: $form_info['id']_$hook $form_info['id']_$form_info['forms'][$step_key]_$hook
1 call to ctools_wizard_defaults()
- ctools_wizard_multistep_form in includes/
wizard.inc - Display a multi-step form.
File
- includes/
wizard.inc, line 483 - CTools' multi-step form wizard tool.
Code
function ctools_wizard_defaults(&$form_info) {
$hook = $form_info['id'];
$defaults = array(
'show trail' => FALSE,
'free trail' => FALSE,
'show back' => FALSE,
'show cancel' => FALSE,
'show return' => FALSE,
'next text' => t('Continue'),
'back text' => t('Back'),
'return text' => t('Update and return'),
'finish text' => t('Finish'),
'cancel text' => t('Cancel'),
);
if (!empty($form_info['free trail'])) {
$defaults['next text'] = t('Update');
$defaults['finish text'] = t('Save');
}
$form_info = $form_info + $defaults;
// Set form callbacks if they aren't defined.
foreach ($form_info['forms'] as $step => $params) {
if (empty($params['form id'])) {
$form_callback = $hook . '_' . $step . '_form';
$form_info['forms'][$step]['form id'] = $form_callback;
}
}
// Set button callbacks.
$callbacks = array(
'back callback' => '_back',
'next callback' => '_next',
'return callback' => '_return',
'cancel callback' => '_cancel',
'finish callback' => '_finish',
);
foreach ($callbacks as $key => $callback) {
// Never overwrite if explicity defined.
if (empty($form_info[$key])) {
$wizard_callback = $hook . $callback;
if (function_exists($wizard_callback)) {
$form_info[$key] = $wizard_callback;
}
}
}
}