public function NodeTabForm::submitForm in Simplenews 8
Same name and namespace in other branches
- 8.2 src/Form/NodeTabForm.php \Drupal\simplenews\Form\NodeTabForm::submitForm()
- 3.x src/Form/NodeTabForm.php \Drupal\simplenews\Form\NodeTabForm::submitForm()
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/ NodeTabForm.php, line 265
Class
- NodeTabForm
- Configure simplenews subscriptions of a user.
Namespace
Drupal\simplenews\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
$node = $form_state
->get('node');
// Save the recipient handler and it's settings.
$node->simplenews_issue->handler = $values['recipient_handler'];
if (!empty($form['recipient_handler_settings'])) {
$handler = $values['recipient_handler'];
$handler_definitions = $this->recipientHandlerManager
->getDefinitions();
$handler = $handler_definitions[$handler];
$class = $handler['class'];
if (method_exists($class, 'settingsFormSubmit')) {
$settings = $class::settingsFormSubmit($form['recipient_handler_settings'], $form_state);
$node->simplenews_issue->handler_settings = (array) $settings;
}
}
$node
->save();
}