public function SubscriptionsAccountForm::buildForm in Simplenews 8.2
Same name and namespace in other branches
- 8 src/Form/SubscriptionsAccountForm.php \Drupal\simplenews\Form\SubscriptionsAccountForm::buildForm()
- 3.x src/Form/SubscriptionsAccountForm.php \Drupal\simplenews\Form\SubscriptionsAccountForm::buildForm()
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 EntityForm::buildForm
File
- src/
Form/ SubscriptionsAccountForm.php, line 18
Class
- SubscriptionsAccountForm
- Configure simplenews subscriptions of a user.
Namespace
Drupal\simplenews\FormCode
public function buildForm(array $form, FormStateInterface $form_state, UserInterface $user = NULL) {
if (isset($user)) {
$form_state
->set('user', $user);
// Load/create a subscriber from the user.
$this
->setEntity(Subscriber::loadByUid($user
->id(), 'create'));
}
return parent::buildForm($form, $form_state);
}