Problem/Motivation
Email FAPI element was added without support of multiple attribute. See https://www.drupal.org/project/drupal/issues/1174620#comment-4564144.
Currently even if the attribute set directly through #attributes
property Drupal does not accept comma-separated emails.
Steps to reproduce
- Add to any form an email element
$form['email'] = [
'#type' => 'email',
'#title' => $this>t('Email'),
];
'#attributes' => ['multiple' => '']
The email address <em>foo@example.com,bar@example.com</em> is not valid. Use the format user@example.com.
Proposed resolution
Support "multiple" attribute same way as for select lists.
$form['emails'] = [
'#type' => 'email',
'#title' => $this->t('Emails'),
'#multiple' => TRUE,
'#description' => $this->t('Comma-separated email addresses.')
];
- Allow to add multiple attribute via #multiple element property
- Update element validation to support #multiple property
Later, it will be possible to add this option to Email fields as well, but first, an element itself needs to comply with the HTML documentation.
Remaining tasks
Confirm there are no implications here for things like \Drupal\Core\Field\Plugin\Field\FieldFormatter\MailToFormatter that expect a single email address.
Items in the MR
#44
#45
Review
Commit
User interface changes
NA
API changes
The API of the Email Render element must be updated.
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21...
Data model changes
NA
Release notes snippet
Provide multiple attribute support for Email render element.