You are here

public function EmailMergeForm::submitForm in Forena Reports 8

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

src/Form/EmailMergeForm.php, line 70

Class

EmailMergeForm

Namespace

Drupal\forena\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $user = \Drupal::currentUser();
  $test_send = $form_state
    ->getValue('send') == 'test';
  $email = $test_send ? $user
    ->getEmail() : '';
  $max = $test_send ? $form_state
    ->getValue('max') : 0;

  /** @var EmailMerge $doc */
  $doc = DocManager::instance()
    ->getDocument();
  $body = $form_state
    ->getValue('body');
  $subject = $form_state
    ->getValue('subject');
  $i = 0;
  if (!empty($body)) {

    // @TODO:  Figure out formatting and wysiwyg.

    //$body =  check_markup($form_state['values']['body']['value'],$form_state['values']['body']['format']);
  }
  $doc
    ->sendMail($email, $max, $subject, $body);
}