Password.php in YAML Form 8
File
src/Plugin/YamlFormElement/Password.php
View source
<?php
namespace Drupal\yamlform\Plugin\YamlFormElement;
use Drupal\yamlform\YamlFormElementBase;
class Password extends YamlFormElementBase {
public function formatText(array &$element, $value, array $options = []) {
$format = $this
->getFormat($element);
switch ($format) {
case 'obscured':
return '********';
default:
return parent::formatText($element, $value, $options);
}
}
public function getDefaultFormat() {
return 'obscured';
}
public function getFormats() {
return parent::getFormats() + [
'obscured' => $this
->t('Obscured'),
];
}
}