public function MailingListExportForm::buildForm in Mailing List 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/ MailingListExportForm.php, line 72
Class
- MailingListExportForm
- Mailing list export.
Namespace
Drupal\mailing_list\FormCode
public function buildForm(array $form, FormStateInterface $form_state, MailingListInterface $mailing_list = NULL) {
$this->mailingList = $mailing_list;
$form['#title'] = $this
->t('Export subscriptions from %label mailing list', [
'%label' => $mailing_list
->label(),
]);
$form['status'] = [
'#type' => 'radios',
'#title' => $this
->t('Filter by status'),
'#options' => [
'' => $this
->t('- any -'),
'active' => $this
->t('Active'),
'inactive' => $this
->t('Inactive'),
],
'#default_value' => $form_state
->getValue('status', ''),
];
if (!empty($this->result)) {
$form['result'] = [
'#type' => 'textarea',
'#title' => $this
->t('Result'),
'#rows' => 10,
'#resizable' => 'vertical',
'#value' => implode("\n", $this->result),
];
}
$form['actions']['apply'] = [
'#type' => 'submit',
'#value' => $this
->t('Export'),
];
return $form;
}