You are here

public function DemoDumpForm::buildForm in Demonstration site (Sandbox / Snapshot) 8

form to create database snapshots.

Overrides FormInterface::buildForm

File

src/Form/DemoDumpForm.php, line 23

Class

DemoDumpForm

Namespace

Drupal\demo\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['#tree'] = TRUE;
  $form['dump']['filename'] = [
    '#title' => t('Name'),
    '#type' => 'textfield',
    '#autocomplete_path' => 'demo/autocomplete',
    '#required' => TRUE,
    '#maxlength' => 128,
    '#description' => t('Allowed characters: a-z, 0-9, dashes ("-"), underscores ("_") and dots.'),
  ];
  $form['dump']['description'] = [
    '#title' => t('Description'),
    '#type' => 'textarea',
    '#rows' => 2,
    '#description' => t('Leave empty to retain the existing description when replacing a snapshot.'),
  ];
  $form['dump']['tables'] = [
    '#type' => 'value',
    '#value' => demo_enum_tables(),
  ];
  $form['actions'] = [
    '#type' => 'actions',
  ];
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => t('Create'),
  ];
  return $form;
}