function jst_timer_form_alter in Javascript Timer 6
Same name and namespace in other branches
- 7 widgets/jst_timer.module \jst_timer_form_alter()
Implementation of hook_form_alter(). Add the timer widget specific settings to admin screen.
File
- widgets/
jst_timer.module, line 286 - Default widget implementation for an up and down timer. This widget does not use hook_ctwidget as it is always included.
Code
function jst_timer_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
//change this to form_id of the form you want to alter
case 'jstimer_admin_settings':
$form['jst_timer'] = array(
'#type' => 'fieldset',
'#title' => t('Timer widget'),
'#weight' => 1,
);
$form['jst_timer']['jstimer_output_overrides'] = array(
'#type' => 'fieldset',
'#title' => t('Output Overrides'),
'#collapsible' => TRUE,
'#description' => t("Output formats change the display of the timer. The global format is used unless you choose a preset in the timer tags. You can hard-code the output format in the timer tags as well. Available replacement values are: %day%, %month%, %year%, %dow%, %moy%, %years%, %ydays%, %days%, %hours%, %mins%, and %secs%."),
);
$form['jst_timer']['jstimer_output_overrides']['jstimer_output_format'] = array(
'#type' => 'textarea',
'#rows' => 2,
'#title' => t('Global output format'),
'#default_value' => variable_get('jstimer_output_format', DEFAULT_OUTPUT_FORMAT),
'#description' => t("The global output format is the baseline unless you use the presets below."),
);
$form['jst_timer']['jstimer_output_overrides']['overrides'][] = array(
'jstimer_output_format_1' => array(
'#type' => 'textarea',
'#rows' => 2,
'#title' => t('Output format preset 1'),
'#default_value' => variable_get('jstimer_output_format_1', DEFAULT_OUTPUT_FORMAT_1),
),
'jstimer_output_format_2' => array(
'#type' => 'textarea',
'#rows' => 2,
'#title' => t('Output format preset 2'),
'#default_value' => variable_get('jstimer_output_format_2', DEFAULT_OUTPUT_FORMAT_2),
),
'jstimer_output_format_3' => array(
'#type' => 'textarea',
'#rows' => 2,
'#title' => t('Output format preset 3'),
'#default_value' => variable_get('jstimer_output_format_3', DEFAULT_OUTPUT_FORMAT_3),
),
);
$form['jst_timer']['highlights'] = array(
'#type' => 'fieldset',
'#title' => t('Highlight settings'),
'#description' => t('When a timer is nearing completion, you can change its\' color or use css formatting.'),
'#tree' => FALSE,
);
$form['jst_timer']['highlights'][] = array(
'jstimer_highlight' => array(
'#type' => 'textfield',
'#size' => 100,
'#title' => t('Highlight tagging'),
'#default_value' => variable_get('jstimer_highlight', DEFAULT_HIGHLIGHT),
'#description' => t("Use style=\"color:red;background-color:white;\" or class=\"\" etc..."),
),
'jstimer_highlight_threshold' => array(
'#type' => 'textfield',
'#size' => 100,
'#title' => t('Highlight threshold (minutes)'),
'#default_value' => variable_get('jstimer_highlight_threshold', DEFAULT_HIGHLIGHT_THRESHOLD),
'#description' => t("Number of minutes left before highlighting is applied."),
),
);
$form['jst_timer']['jstimer_complete_statement'] = array(
'#type' => 'textfield',
'#size' => 100,
'#title' => t('Timer complete statement'),
'#default_value' => variable_get('jstimer_complete_statement', DEFAULT_TIMER_COMPLETE),
'#description' => t("Statement that prints when a timer has completed."),
);
// Redirect URL.
$form['jst_timer']['actions']['redirect'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Timer complete redirect'),
'#description' => t('Javascript redirect/refresh that runs when a countdown completes.'),
'#tree' => FALSE,
);
$form['jst_timer']['actions']['redirect']['jst_timer_redirect_path'] = array(
'#type' => 'textfield',
'#size' => 100,
'#title' => t('Redirect path'),
'#default_value' => variable_get('jst_timer_redirect_path', ''),
'#description' => t('An absolute URL or %reload for same page.', array(
'%reload' => '<reload>',
)),
);
$form['buttons']['#weight'] = 2;
break;
}
}