function jst_timer_admin_settings_submit in Javascript Timer 8
Same name and namespace in other branches
- 7 widgets/jst_timer.module \jst_timer_admin_settings_submit()
1 string reference to 'jst_timer_admin_settings_submit'
- jst_timer_form_jstimer_admin_settings_alter in widgets/
jst_timer.module - Implementation of hook_form_alter(). Add the timer widget specific settings to admin screen.
File
- widgets/
jst_timer.module, line 479 - 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_admin_settings_submit($form, FormStateInterface $form_state) {
$config = \Drupal::configFactory()
->getEditable('jstimer.settings');
// Remove any blank formats.
$formats = $form_state
->getValue('jst_timer_formats');
foreach ($formats as $i => $format) {
if ($format == '') {
unset($formats[$i]);
}
}
$config
->set('jst_timer_formats', $formats);
$config
->set('jstimer_highlight', $form_state
->getValue('jstimer_highlight'));
$config
->set('jstimer_highlight_threshold', $form_state
->getValue('jstimer_highlight_threshold'));
$config
->set('jstimer_highlight_down', $form_state
->getValue('jstimer_highlight_down'));
$config
->set('jstimer_highlight_up', $form_state
->getValue('jstimer_highlight_up'));
$config
->set('jst_timer_redirect_path', $form_state
->getValue('jst_timer_redirect_path'));
$config
->set('jst_timer_redirect_delay', $form_state
->getValue('jst_timer_redirect_delay'));
$config
->set('jst_timer_complete_message', $form_state
->getValue('jst_timer_complete_message'));
$config
->set('jst_timer_complete_alert_message', $form_state
->getValue('jst_timer_complete_alert_message'));
$config
->save();
\Drupal::messenger()
->addStatus(t('Remember to "reload" the page. Most browsers will cache the javascript file.'));
}