public function DemoManageForm::buildForm in Demonstration site (Sandbox / Snapshot) 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- src/
Form/ DemoManageForm.php, line 23
Class
- DemoManageForm
- Returns demo_manage_form where you can see reset dates and all.
Namespace
Drupal\demo\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form['status'] = [
'#type' => 'container',
'#title' => t('Status'),
'#attributes' => [
'class' => [
'demo-status',
'clearfix',
],
],
'#attached' => [
'library' => [
'demo/demo-library',
],
],
];
$reset_date = \Drupal::config('demo.settings')
->get('demo_reset_last', 0);
$form['status']['reset_last'] = [
'#type' => 'item',
'#title' => t('Last reset'),
'#markup' => $reset_date ? \Drupal::service('date.formatter')
->format($reset_date) : t('Never'),
];
$form['dump'] = demo_get_dumps();
$form['actions'] = [
'#type' => 'actions',
];
$form['actions']['delete'] = [
'#type' => 'submit',
'#value' => t('Delete'),
'#submit' => [
'demo_manage_delete_submit',
],
];
// If there are no snapshots yet, hide the selection and form actions.
if (empty($form['dump']['#options'])) {
$form['dump']['#access'] = FALSE;
$form['actions']['#access'] = FALSE;
}
return $form;
}