Obscure.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Form text element
  8. *
  9. * @author Magento Core Team <core@magentocommerce.com>
  10. */
  11. namespace Magento\Framework\Data\Form\Element;
  12. class Obscure extends \Magento\Framework\Data\Form\Element\Password
  13. {
  14. /**
  15. * @var string
  16. */
  17. protected $_obscuredValue = '******';
  18. /**
  19. * Hide value to make sure it will not show in HTML
  20. *
  21. * @param string $index
  22. * @return string
  23. */
  24. public function getEscapedValue($index = null)
  25. {
  26. $value = parent::getEscapedValue($index);
  27. if (!empty($value)) {
  28. return $this->_obscuredValue;
  29. }
  30. return $value;
  31. }
  32. /**
  33. * Returns list of html attributes possible to output in HTML
  34. *
  35. * @return string[]
  36. */
  37. public function getHtmlAttributes()
  38. {
  39. return [
  40. 'type',
  41. 'title',
  42. 'class',
  43. 'style',
  44. 'onclick',
  45. 'onchange',
  46. 'onkeyup',
  47. 'disabled',
  48. 'readonly',
  49. 'maxlength',
  50. 'tabindex',
  51. 'data-form-part',
  52. 'data-role',
  53. 'data-action'
  54. ];
  55. }
  56. }