function jst_clock_form_jstimer_admin_settings_alter in Javascript Timer 8
Implementation of hook_form_alter(). Add the clock widget specific settings to admin screen.
File
- widgets/
jst_clock.module, line 271 - Embeddable clock widget (optional).
Code
function jst_clock_form_jstimer_admin_settings_alter(&$form, FormStateInterface $form_state, $form_id) {
$config = \Drupal::config('jstimer.settings');
$form['jst_clock'] = array(
'#type' => 'fieldset',
'#title' => t('Clock widget'),
'#weight' => 5,
);
$form['jst_clock']['jstimer_jst_clock_demo'] = array(
'#markup' => '<div class="jst_clock"></div>' . t('After saving, you need to reload the page to see the new clock.'),
);
$form['jst_clock']['jstimer_jst_clock_type'] = array(
'#type' => 'radios',
'#title' => t('Clock type'),
'#default_value' => $config
->get('jstimer_jst_clock_type'),
'#options' => array(
0 => t('12-hour plain text'),
1 => t('24-hour plain text'),
2 => t('Analog canvas'),
3 => t('Analog SVG'),
),
'#description' => t("The analog clocks are experimental and only works on Firefox, Opera, and Safari and IE9."),
);
$form['jst_clock']['jst_clock_sva_file'] = array(
'#type' => 'textfield',
'#title' => t('Clock svg file'),
'#default_value' => $config
->get('jst_clock_sva_file'),
'#description' => t('The name of the svg file to use for the SVG clock. They are stored in the widgets/clocks sub directory.'),
);
$form['buttons']['#weight'] = 10;
// Put this module's submit handler first so it can save before javascript file is built.
array_unshift($form['#submit'], 'jst_clock_admin_settings_submit');
}