function demo_form_alter in Demonstration site (Sandbox / Snapshot) 8
Implements hook_form_FORMID_alter().
File
- ./
demo.module, line 845
Code
function demo_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'demo_manage_form') {
$form['status']['demo_reset_default'] = [
'#type' => 'item',
'#title' => t('Default snapshot'),
'#markup' => SafeMarkup::checkPlain(\Drupal::config('demo.settings')
->get('demo_dump_cron', t('- None -'))),
];
$demo_dump_cron = \Drupal::config('demo.settings')
->get('demo_dump_cron', 'Set default value');
foreach ($form['dump'] as $name => $option) {
if ($name == $demo_dump_cron) {
$form['dump'][$name]['#value'] = $name;
break;
}
}
$form['actions']['cron'] = [
'#type' => 'submit',
'#value' => t('Use for cron runs'),
'#submit' => [
'demo_reset_demo_manage_form_submit',
],
];
}
elseif ($form_id == 'demo_dump_form') {
$form['dump']['default'] = [
'#title' => t('Use as default snapshot for cron runs'),
'#type' => 'checkbox',
];
}
}