sfWidgetFormInputPassword.class.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * sfWidgetFormInputPassword represents a password HTML input tag.
  11. *
  12. * @package symfony
  13. * @subpackage widget
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. * @version SVN: $Id: sfWidgetFormInputPassword.class.php 9046 2008-05-19 08:13:51Z FabianLange $
  16. */
  17. class sfWidgetFormInputPassword extends sfWidgetFormInput
  18. {
  19. /**
  20. * Configures the current widget.
  21. *
  22. * Available options:
  23. *
  24. * * always_render_empty: true if you want the input value to be always empty when rendering (true by default)
  25. *
  26. * @param array $options An array of options
  27. * @param array $attributes An array of default HTML attributes
  28. *
  29. * @see sfWidgetFormInput
  30. */
  31. protected function configure($options = array(), $attributes = array())
  32. {
  33. parent::configure($options, $attributes);
  34. $this->addOption('always_render_empty', true);
  35. $this->setOption('type', 'password');
  36. }
  37. /**
  38. * @param string $name The element name
  39. * @param string $value The password stored in this widget, will be masked by the browser.
  40. * @param array $attributes An array of HTML attributes to be merged with the default HTML attributes
  41. * @param array $errors An array of errors for the field
  42. *
  43. * @return string An HTML tag string
  44. *
  45. * @see sfWidgetForm
  46. */
  47. public function render($name, $value = null, $attributes = array(), $errors = array())
  48. {
  49. return parent::render($name, $this->getOption('always_render_empty') ? null : $value, $attributes, $errors);
  50. }
  51. }