Skip to content

Commit

Permalink
FORSLAG-77: Added allow email field on support
Browse files Browse the repository at this point in the history
  • Loading branch information
rimi-itk committed Aug 22, 2023
1 parent b93a422 commit 822a82a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#default_value' => $adminFormStateValues['support_email_help'] ?? '',
];

$form['support_form']['support_allow_email_help'] = [
'#type' => 'textfield',
'#title' => $this->t('Allow email help'),
'#default_value' => $adminFormStateValues['support_allow_email_help'] ?? '',
'#description' => $this->t('Use <code>&lt;a target=&quot;_blank&quot; href=&quot;…&quot;&gt;Read more about the emails we may send&lt;/a&gt;</code> to insert a link to details on what emails might be sent.'),
];

$form['support_form']['support_goto_url'] = [
'#type' => 'textfield',
'#title' => $this->t('Redirect URL after a proposal has been supported'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,26 @@ protected function buildProposalForm(array $form, FormStateInterface $formState)

$form['email'] = [
'#type' => 'email',
'#required' => TRUE,
'#title' => $this
->t('Email'),
'#default_value' => $defaltValues['email'],
'#description' => $this->getAdminFormStateValue('support_email_help'),
'#description_display' => 'before',
];

$form['allow_email'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Allow email'),
'#default_value' => $defaltValues['support_allow_email_help'] ?? FALSE,
'#description' => $this->getAdminFormStateValue('support_allow_email_help'),
'#states' => [
'visible' => [
':input[name="email"]' => ['filled' => TRUE],
],
],
];

$form['consent'] = [
'#type' => 'checkbox',
'#title' => $this
Expand Down Expand Up @@ -154,6 +166,7 @@ public function submitForm(array &$form, FormStateInterface $form_state): void {
[
'user_name' => $form_state->getValue('name'),
'user_email' => $form_state->getValue('email'),
'allow_email' => $form_state->getValue('allow_email'),
],
);
$this->messenger()->addStatus($this->getAdminFormStateValue('support_submission_text', $this->t('Thank you for your support.')));
Expand Down

0 comments on commit 822a82a

Please sign in to comment.