*/ class Zend_Form_Decorator_JsValidation extends Zend_Form_Decorator_Abstract { /** * The name of the form * @var string */ protected $_formName; /** * The namespace that will be used for the forms in JavaScript * @var string */ protected $_formNamespace = 'Forms'; /** * Where to look for Zend/*.js files * @var string */ protected $_javaScriptPath; /** * JavaScript function called for valid elements * @var string */ protected $_validElementCallback; /** * JavaScript function called for invalid elements * @var string */ protected $_invalidElementCallback; /** * Unique ID counter for generated form names * @var int */ protected static $_uniqueId = 0; public function __construct($options = array()) { if(isset($options['formNamespace'])) $this->_formNamespace = $options['formNamespace']; if(isset($options['javaScriptPath'])) $this->_javaScriptPath = $options['javaScriptPath']; else $this->_javaScriptPath = Zend_Controller_Front::getInstance()->getBaseUrl() . '/js/'; if(isset($options['validElementCallback'])) $this->_validElementCallback = $options['validElementCallback']; if(isset($options['invalidElementCallback'])) $this->_invalidElementCallback = $options['invalidElementCallback']; } public function render($content) { $this->_formName = $this->getElement()->getName(); if(!$this->_formName) { $this->_formName = 'zend_form_' . self::$_uniqueId; self::$_uniqueId++; $content = preg_replace('/