File indexing completed on 2025-02-09 07:19:56

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Form
0017  * @subpackage Element
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  */
0021 
0022 /** Zend_Form_Element_Xhtml */
0023 // require_once 'Zend/Form/Element/Xhtml.php';
0024 
0025 /**
0026  * Password form element
0027  *
0028  * @category   Zend
0029  * @package    Zend_Form
0030  * @subpackage Element
0031  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0032  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0033  * @version    $Id$
0034  */
0035 class Zend_Form_Element_Password extends Zend_Form_Element_Xhtml
0036 {
0037     /**
0038      * Use formPassword view helper by default
0039      * @var string
0040      */
0041     public $helper = 'formPassword';
0042 
0043     /**
0044      * Whether or not to render the password
0045      * @var bool
0046      */
0047     public $renderPassword = false;
0048 
0049     /**
0050      * Set flag indicating whether or not to render the password
0051      * @param  bool $flag
0052      * @return Zend_Form_Element_Password
0053      */
0054     public function setRenderPassword($flag)
0055     {
0056         $this->renderPassword = (bool) $flag;
0057         return $this;
0058     }
0059 
0060     /**
0061      * Get value of renderPassword flag
0062      *
0063      * @return bool
0064      */
0065     public function renderPassword()
0066     {
0067         return $this->renderPassword;
0068     }
0069 
0070     /**
0071      * Override isValid()
0072      *
0073      * Ensure that validation error messages mask password value.
0074      *
0075      * @param  string $value
0076      * @param  mixed $context
0077      * @return bool
0078      */
0079     public function isValid($value, $context = null)
0080     {
0081         foreach ($this->getValidators() as $validator) {
0082             if ($validator instanceof Zend_Validate_Abstract) {
0083                 $validator->setObscureValue(true);
0084             }
0085         }
0086         return parent::isValid($value, $context);
0087     }
0088 }