getFilter('StringTrim')) { $this->addFilter('StringTrim'); } return $this; } /** * Set flag indicating whether or not to auto-register alias validator * * @param bool $flag * @return Qs_Form_Element_PageAlias */ public function setRegisterAliasValidator($flag) { $this->_registerAliasValidator = (bool) $flag; return $this; } /** * Set description for element * * @return Qs_Form_Element_PageAlias */ protected function _initElementDescription() { if ($this->hasRegisterAliasValidator() && empty($this->_description)) { $this->_description = $this->_defaultDescription; } return $this; } /** * Get status of auto-register alias validator flag * * @return bool */ public function hasRegisterAliasValidator() { return $this->_registerAliasValidator; } /** * Is the value provided valid? * * Autoregisters alias validator if necessary. * * @param string $value * @param mixed $context * @return bool * @throws Zend_Form_Element_Exception */ public function isValid($value, $context = null) { if ($this->hasRegisterAliasValidator()) { if (!$this->getValidator('Alias')) { $options = $this->getAliasValidatorOptions(); if (empty($options)) { throw new Zend_Form_Element_Exception('Alias validator options is not defined'); } $this->addValidator( 'Alias', true, [$options] ); } } return parent::isValid($value, $context); } /** * Set options for alias validator * * @param array $options * @return Qs_Form_Element_PageAlias */ public function setAliasValidatorOptions($options) { $this->_aliasValidatorOptions = $options; return $this; } /** * Return options for alias validator * * @return array */ public function getAliasValidatorOptions() { return $this->_aliasValidatorOptions; } public function render(Zend_View_Interface $view = null) { $this->_initElementDescription(); return parent::render($view); } }