public function EmailMergeForm::buildForm in Forena Reports 8
Form constructor.
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 The form structure.
Overrides FormInterface::buildForm
File
- src/
Form/ EmailMergeForm.php, line 22
Class
Namespace
Drupal\forena\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
/** @var EmailMerge $d */
$d = DocManager::instance()
->getDocument();
$input_format = \Drupal::config('forena.settings')
->get('email_input_format');
$email_override = \Drupal::config('forena.settings')
->get('email_override');
$values = $form_state
->getValues();
$form['subject'] = [
'#type' => 'textfield',
'#title' => t('Subject'),
'#access' => $d->prompt_subject,
];
$form['body'] = array(
'#type' => 'text_format',
'#title' => t('Message'),
'#default_value' => @$values['body'],
'#format' => $input_format,
'#access' => $d->prompt_body,
);
$form['send'] = array(
'#type' => 'radios',
'#title' => t('Send Email'),
'#options' => array(
'send' => 'email to users',
'test' => 'emails to me (test mode)',
),
'#default_value' => 'test',
'#access' => !$email_override,
);
$form['max'] = array(
'#type' => 'textfield',
'#title' => 'Only send first',
'#description' => 'In test mode only, limits the number of messages to send',
'#default_value' => 1,
'#size' => 3,
);
$form['actions'] = [
'#type' => 'actions',
];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Email'),
];
return $form;
}