Skip to content

Commit

Permalink
Make subscribe form work
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylichtman committed Feb 23, 2016
1 parent a097bc6 commit 2f179b8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Form/SubscribeForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,23 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
foreach($form_state['values']['lists'] as $list_id) {
$values = $form_state->getValues();
foreach($values['lists'] as $list_id) {

if(!$list_id) {
continue;
}

$email = check_plain($form_state['values']['email']);
$email_okay = \Drupal::service('email.validator')->isValid($values['email']);
if ($email_okay) {
$email = $values['email'];
}
else {
form_set_error('', t('Please submit a valid email address.'));
$form_state['redirect'] = FALSE;
return FALSE;
}

$cm = CampaignMonitor::getConnector();

// Update subscriber information or add new subscriber to the list.
Expand Down

0 comments on commit 2f179b8

Please sign in to comment.