Password.php in Webform 6.x
File
src/Plugin/WebformElement/Password.php
View source
<?php
namespace Drupal\webform\Plugin\WebformElement;
use Drupal\webform\Plugin\WebformElementBase;
use Drupal\webform\WebformSubmissionInterface;
class Password extends WebformElementBase {
protected function formatTextItem(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
$value = $this
->getValue($element, $webform_submission, $options);
if ($value === '' || $value === NULL) {
return '';
}
$format = $this
->getItemFormat($element);
switch ($format) {
case 'obscured':
return '********';
default:
return parent::formatTextItem($element, $webform_submission, $options);
}
}
public function getItemDefaultFormat() {
return 'obscured';
}
public function getItemFormats() {
return parent::getItemFormats() + [
'obscured' => $this
->t('Obscured'),
];
}
}