You are here

public function WebformSignature::form in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/WebformSignature.php \Drupal\webform\Plugin\WebformElement\WebformSignature::form()

Gets the actual configuration webform array to be built.

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 An associative array contain the element's configuration webform without any default values.

Overrides WebformElementBase::form

File

src/Plugin/WebformElement/WebformSignature.php, line 193

Class

WebformSignature
Provides a 'signature' element.

Namespace

Drupal\webform\Plugin\WebformElement

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);

  // Warn people about saving signatures when saving of results is disabled.

  /** @var \Drupal\webform\WebformInterface $webform */
  $webform = $form_state
    ->getFormObject()
    ->getWebform();
  if ($webform
    ->isResultsDisabled()) {
    $image_directory = 'public://webform/' . $webform
      ->id() . '/{element_key}';
    $form['signature'] = [
      '#type' => 'fieldset',
      '#title' => $this
        ->t('Signature settings'),
      '#access' => TRUE,
    ];
    $form['signature']['signature_message'] = [
      '#type' => 'webform_message',
      '#message_message' => '<strong>' . $this
        ->t('Saving of results is disabled.') . '</strong> ' . $this
        ->t('Signatures will still be saved to %directory.', [
        '%directory' => $image_directory,
      ]),
      '#message_type' => 'warning',
      '#access' => TRUE,
    ];
  }
  return $form;
}