You are here

public function EncryptionProfileTestForm::form in Encrypt 8.3

Gets the actual form array to be built.

Overrides EntityForm::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

File

src/Form/EncryptionProfileTestForm.php, line 44

Class

EncryptionProfileTestForm
Provides a form for testing encryption / decryption on a given profile.

Namespace

Drupal\encrypt\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $form['encrypt'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Encryption test'),
    '#open' => TRUE,
  ];
  $form['encrypt']['to_encrypt'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Text to encrypt'),
    '#description' => $this
      ->t('Specify the text you want to encrypt with this encryption profile. The result of the encryption will be shown below.'),
  ];
  $form['encrypt']['encrypt_base64'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Base64-encode the encrypted text.'),
  ];
  $form['encrypt']['encrypt_text'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Encrypt'),
    '#name' => 'encrypt',
  ];
  $form['encrypt']['encrypted'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Encrypted text'),
    '#value' => $form_state
      ->getValue('encrypted'),
    '#disabled' => TRUE,
  ];
  $form['decrypt'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Decryption test'),
    '#open' => TRUE,
  ];
  $form['decrypt']['to_decrypt'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Text to decrypt'),
    '#description' => $this
      ->t('Specify the text you want to decrypt with this encryption profile. The result of the decryption will be shown below.'),
  ];
  $form['decrypt']['decrypt_base64'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Base64-decode the encrypted text before decrypting.'),
  ];
  $form['decrypt']['decrypt_text'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Decrypt'),
    '#name' => 'decrypt',
  ];
  $form['decrypt']['decrypted'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Decrypted text'),
    '#value' => $form_state
      ->getValue('decrypted'),
    '#disabled' => TRUE,
  ];
  return $form;
}