/** * Override isValid() * * Ensure that validation error messages mask password value. * * @param string $value * @param mixed $context * @return bool */ public function isValid($value, $context = null) { foreach ($this->getValidators() as $validator) { if ($validator instanceof IfwPsn_Vendor_Zend_Validate_Abstract) { $validator->setObscureValue(true); } } return parent::isValid($value, $context); }
/** * Return label * * If no label is present, returns the currently set name. * * If a translator is present, returns the translated label. * * @return string */ public function getLabel() { $value = parent::getLabel(); if (null === $value) { $value = $this->getName(); if (null !== ($translator = $this->getTranslator())) { return $translator->translate($value); } } return $value; }
/** * Is the value provided valid? * * Autoregisters InArray validator if necessary. * * @param string $value * @param mixed $context * @return bool */ public function isValid($value, $context = null) { if ($this->registerInArrayValidator()) { if (!$this->getValidator('InArray')) { $multiOptions = $this->getMultiOptions(); $options = array(); foreach ($multiOptions as $opt_value => $opt_label) { // optgroup instead of option label if (is_array($opt_label)) { $options = array_merge($options, array_keys($opt_label)); } else { $options[] = $opt_value; } } $this->addValidator('InArray', true, array($options)); } } return parent::isValid($value, $context); }
/** * Render CSRF token in form * * @param IfwPsn_Vendor_Zend_View_Interface $view * @return string */ public function render(IfwPsn_Vendor_Zend_View_Interface $view = null) { $this->initCsrfToken(); return parent::render($view); }
/** * Is the captcha valid? * * @param mixed $value * @param mixed $context * @return boolean */ public function isValid($value, $context = null) { $this->getCaptcha()->setName($this->getName()); $belongsTo = $this->getBelongsTo(); if (empty($belongsTo) || !is_array($context)) { return parent::isValid($value, $context); } $name = $this->getFullyQualifiedName(); $root = substr($name, 0, strpos($name, '[')); $segments = substr($name, strpos($name, '[')); $segments = ltrim($segments, '['); $segments = rtrim($segments, ']'); $segments = explode('][', $segments); array_unshift($segments, $root); array_pop($segments); $newContext = $context; foreach ($segments as $segment) { if (array_key_exists($segment, $newContext)) { $newContext = $newContext[$segment]; } } return parent::isValid($value, $newContext); }
/** * Set value * * If value matches checked value, sets to that value, and sets the checked * flag to true. * * Any other value causes the unchecked value to be set as the current * value, and the checked flag to be set as false. * * * @param mixed $value * @return IfwPsn_Vendor_Zend_Form_Element_Checkbox */ public function setValue($value) { if ($value == $this->getCheckedValue()) { parent::setValue($value); $this->checked = true; } else { parent::setValue($this->getUncheckedValue()); $this->checked = false; } return $this; }
/** * Render form element * Checks for decorator interface to prevent errors * * @param IfwPsn_Vendor_Zend_View_Interface $view * @return string * @throws IfwPsn_Vendor_Zend_Form_Element_Exception */ public function render(IfwPsn_Vendor_Zend_View_Interface $view = null) { $marker = false; foreach ($this->getDecorators() as $decorator) { if ($decorator instanceof IfwPsn_Vendor_Zend_Form_Decorator_Marker_File_Interface) { $marker = true; } } if (!$marker) { require_once IFW_PSN_LIB_ROOT . 'IfwPsn/Vendor/Zend/Form/Element/Exception.php'; throw new IfwPsn_Vendor_Zend_Form_Element_Exception('No file decorator found... unable to render file element'); } return parent::render($view); }