DemoConfigManageForm.php in Demonstration site (Sandbox / Snapshot) 8
File
src/Form/DemoConfigManageForm.php
View source
<?php
namespace Drupal\demo\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
class DemoConfigManageForm extends FormBase {
public function getFormId() {
return 'demo_config_manage_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form['actions'] = [
'#type' => 'actions',
];
$form['description'] = [
'#type' => 'item',
'#description' => t('This will create snapshot of the configuration of your drupal site.'),
];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => t('+ Create snapshot'),
'#attributes' => [
'class' => [
'btn-primary',
],
],
];
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
if ($form_state
->setRedirect('demo.export_download')) {
\Drupal::messenger()
->addMessage(t('Snapshot has been created.'));
}
else {
\Drupal::messenger()
->addMessage(t('Snapshot not created.'));
}
}
}
Classes
Name |
Description |
DemoConfigManageForm |
This class returns the demo_config_manage_form in which there will be a button to create the snapshot of the configuration. |