YamlFormEmailMultiple.php in YAML Form 8
File
src/Plugin/YamlFormElement/YamlFormEmailMultiple.php
View source
<?php
namespace Drupal\yamlform\Plugin\YamlFormElement;
class YamlFormEmailMultiple extends Email {
public function formatHtml(array &$element, $value, array $options = []) {
if (empty($value)) {
return '';
}
$format = $this
->getFormat($element);
switch ($format) {
case 'link':
$emails = preg_split('/\\s*,\\s*/', $value);
$total = count($emails);
$i = 0;
$links = [];
foreach ($emails as $email) {
$links[] = [
'#type' => 'link',
'#title' => $email,
'#url' => \Drupal::pathValidator()
->getUrlIfValid('mailto:' . $email),
'#suffix' => ++$i !== $total ? ', ' : '',
];
}
return $links;
default:
return parent::formatHtml($element, $value, $options);
}
}
}