Index: library/Zend/Form/Element.php =================================================================== --- library/Zend/Form/Element.php (revision 13576) +++ library/Zend/Form/Element.php (working copy) @@ -25,8 +25,8 @@ require_once 'Zend/Validate/Interface.php'; /** - * Zend_Form_Element - * + * Zend_Form_Element + * * @category Zend * @package Zend_Form * @subpackage Element @@ -68,7 +68,7 @@ protected $_belongsTo; /** - * Element decorators + * Element decorators * @var array */ protected $_decorators = array(); @@ -204,8 +204,8 @@ * - string: name of element * - array: options with which to configure element * - Zend_Config: Zend_Config with options for configuring element - * - * @param string|array|Zend_Config $spec + * + * @param string|array|Zend_Config $spec * @return void * @throws Zend_Form_Exception if no element name after initialization */ @@ -217,8 +217,8 @@ $this->setOptions($spec); } elseif ($spec instanceof Zend_Config) { $this->setConfig($spec); - } - + } + if (is_string($spec) && is_array($options)) { $this->setOptions($options); } elseif (is_string($spec) && ($options instanceof Zend_Config)) { @@ -243,7 +243,7 @@ /** * Initialize object; used by extending classes - * + * * @return void */ public function init() @@ -252,8 +252,8 @@ /** * Set flag to disable loading default decorators - * - * @param bool $flag + * + * @param bool $flag * @return Zend_Form_Element */ public function setDisableLoadDefaultDecorators($flag) @@ -264,7 +264,7 @@ /** * Should we load the default decorators? - * + * * @return bool */ public function loadDefaultDecoratorsIsDisabled() @@ -274,7 +274,7 @@ /** * Load default decorators - * + * * @return void */ public function loadDefaultDecorators() @@ -288,15 +288,16 @@ $this->addDecorator('ViewHelper') ->addDecorator('Errors') ->addDecorator('Description', array('tag' => 'p', 'class' => 'description')) - ->addDecorator('HtmlTag', array('tag' => 'dd')) + ->addDecorator('HtmlTag', array('tag' => 'dd', + 'id' => $this->getName() . '-element')) ->addDecorator('Label', array('tag' => 'dt')); } } /** * Set object state from options array - * - * @param array $options + * + * @param array $options * @return Zend_Form_Element */ public function setOptions(array $options) @@ -336,8 +337,8 @@ /** * Set object state from Zend_Config object - * - * @param Zend_Config $config + * + * @param Zend_Config $config * @return Zend_Form_Element */ public function setConfig(Zend_Config $config) @@ -350,8 +351,8 @@ /** * Set translator object for localization - * - * @param Zend_Translate|null $translator + * + * @param Zend_Translate|null $translator * @return Zend_Form_Element */ public function setTranslator($translator = null) @@ -371,7 +372,7 @@ /** * Retrieve localization translator object - * + * * @return Zend_Translate_Adapter|null */ public function getTranslator() @@ -389,8 +390,8 @@ /** * Indicate whether or not translation should be disabled - * - * @param bool $flag + * + * @param bool $flag * @return Zend_Form_Element */ public function setDisableTranslator($flag) @@ -401,7 +402,7 @@ /** * Is translation disabled? - * + * * @return bool */ public function translatorIsDisabled() @@ -413,8 +414,8 @@ /** * Filter a name to only allow valid variable characters - * - * @param string $value + * + * @param string $value * @param bool $allowBrackets * @return string */ @@ -429,8 +430,8 @@ /** * Set element name - * - * @param string $name + * + * @param string $name * @return Zend_Form_Element */ public function setName($name) @@ -447,7 +448,7 @@ /** * Return element name - * + * * @return string */ public function getName() @@ -459,7 +460,7 @@ * Get fully qualified name * * Places name as subitem of array and/or appends brackets. - * + * * @return string */ public function getFullyQualifiedName() @@ -479,7 +480,7 @@ /** * Get element id - * + * * @return string */ public function getId() @@ -508,8 +509,8 @@ /** * Set element value - * - * @param mixed $value + * + * @param mixed $value * @return Zend_Form_Element */ public function setValue($value) @@ -520,9 +521,9 @@ /** * Filter a value - * - * @param string $value - * @param string $key + * + * @param string $value + * @param string $key * @return void */ protected function _filterValue(&$value, &$key) @@ -534,7 +535,7 @@ /** * Retrieve filtered element value - * + * * @return mixed */ public function getValue() @@ -552,7 +553,7 @@ /** * Retrieve unfiltered element value - * + * * @return mixed */ public function getUnfilteredValue() @@ -562,8 +563,8 @@ /** * Set element label - * - * @param string $label + * + * @param string $label * @return Zend_Form_Element */ public function setLabel($label) @@ -574,7 +575,7 @@ /** * Retrieve element label - * + * * @return string */ public function getLabel() @@ -584,8 +585,8 @@ /** * Set element order - * - * @param int $order + * + * @param int $order * @return Zend_Form_Element */ public function setOrder($order) @@ -596,7 +597,7 @@ /** * Retrieve element order - * + * * @return int */ public function getOrder() @@ -606,7 +607,7 @@ /** * Set required flag - * + * * @param bool $flag Default value is true * @return Zend_Form_Element */ @@ -618,7 +619,7 @@ /** * Is the element required? - * + * * @return bool */ public function isRequired() @@ -628,8 +629,8 @@ /** * Set flag indicating whether a NotEmpty validator should be inserted when element is required - * - * @param bool $flag + * + * @param bool $flag * @return Zend_Form_Element */ public function setAutoInsertNotEmptyValidator($flag) @@ -640,7 +641,7 @@ /** * Get flag indicating whether a NotEmpty validator should be inserted when element is required - * + * * @return bool */ public function autoInsertNotEmptyValidator() @@ -650,8 +651,8 @@ /** * Set element description - * - * @param string $description + * + * @param string $description * @return Zend_Form_Element */ public function setDescription($description) @@ -662,7 +663,7 @@ /** * Retrieve element description - * + * * @return string */ public function getDescription() @@ -675,8 +676,8 @@ * * When the allow empty flag is enabled and the required flag is false, the * element will validate with empty values. - * - * @param bool $flag + * + * @param bool $flag * @return Zend_Form_Element */ public function setAllowEmpty($flag) @@ -687,7 +688,7 @@ /** * Get 'allow empty' flag - * + * * @return bool */ public function getAllowEmpty() @@ -697,8 +698,8 @@ /** * Set ignore flag (used when retrieving values at form level) - * - * @param bool $flag + * + * @param bool $flag * @return Zend_Form_Element */ public function setIgnore($flag) @@ -709,7 +710,7 @@ /** * Get ignore flag (used when retrieving values at form level) - * + * * @return bool */ public function getIgnore() @@ -719,8 +720,8 @@ /** * Set flag indicating if element represents an array - * - * @param bool $flag + * + * @param bool $flag * @return Zend_Form_Element */ public function setIsArray($flag) @@ -731,7 +732,7 @@ /** * Is the element representing an array? - * + * * @return bool */ public function isArray() @@ -741,8 +742,8 @@ /** * Set array to which element belongs - * - * @param string $array + * + * @param string $array * @return Zend_Form_Element */ public function setBelongsTo($array) @@ -757,7 +758,7 @@ /** * Return array name to which element belongs - * + * * @return string */ public function getBelongsTo() @@ -767,7 +768,7 @@ /** * Return element type - * + * * @return string */ public function getType() @@ -781,9 +782,9 @@ /** * Set element attribute - * - * @param string $name - * @param mixed $value + * + * @param string $name + * @param mixed $value * @return Zend_Form_Element * @throws Zend_Form_Exception for invalid $name values */ @@ -806,8 +807,8 @@ /** * Set multiple attributes at once - * - * @param array $attribs + * + * @param array $attribs * @return Zend_Form_Element */ public function setAttribs(array $attribs) @@ -821,8 +822,8 @@ /** * Retrieve element attribute - * - * @param string $name + * + * @param string $name * @return string */ public function getAttrib($name) @@ -837,7 +838,7 @@ /** * Return all attributes - * + * * @return array */ public function getAttribs() @@ -856,8 +857,8 @@ * Overloading: retrieve object property * * Prevents access to properties beginning with '_'. - * - * @param string $key + * + * @param string $key * @return mixed */ public function __get($key) @@ -890,9 +891,9 @@ * Overloading: allow rendering specific decorators * * Call renderDecoratorName() to render a specific decorator. - * - * @param string $method - * @param array $args + * + * @param string $method + * @param array $args * @return string * @throws Zend_Form_Exception for invalid decorator or invalid method call */ @@ -921,8 +922,8 @@ /** * Set plugin loader to use for validator or filter chain - * - * @param Zend_Loader_PluginLoader_Interface $loader + * + * @param Zend_Loader_PluginLoader_Interface $loader * @param string $type 'decorator', 'filter', or 'validate' * @return Zend_Form_Element * @throws Zend_Form_Exception on invalid type @@ -945,10 +946,10 @@ /** * Retrieve plugin loader for validator or filter chain * - * Instantiates with default rules if none available for that type. Use + * Instantiates with default rules if none available for that type. Use * 'decorator', 'filter', or 'validate' for $type. - * - * @param string $type + * + * @param string $type * @return Zend_Loader_PluginLoader * @throws Zend_Loader_Exception on invalid type. */ @@ -981,15 +982,15 @@ /** * Add prefix path for plugin loader * - * If no $type specified, assumes it is a base path for both filters and + * If no $type specified, assumes it is a base path for both filters and * validators, and sets each according to the following rules: * - decorators: $prefix = $prefix . '_Decorator' * - filters: $prefix = $prefix . '_Filter' * - validators: $prefix = $prefix . '_Validate' * * Otherwise, the path prefix is set on the appropriate plugin loader. - * - * @param string $path + * + * @param string $path * @return Zend_Form_Element * @throws Zend_Form_Exception for invalid type */ @@ -1022,15 +1023,15 @@ /** * Add many prefix paths at once - * - * @param array $spec + * + * @param array $spec * @return Zend_Form_Element */ public function addPrefixPaths(array $spec) { if (isset($spec['prefix']) && isset($spec['path'])) { return $this->addPrefixPath($spec['prefix'], $spec['path']); - } + } foreach ($spec as $type => $paths) { if (is_numeric($type) && is_array($paths)) { $type = null; @@ -1068,10 +1069,10 @@ * Add validator to validation chain * * Note: will overwrite existing validators if they are of the same class. - * - * @param string|Zend_Validate_Interface $validator + * + * @param string|Zend_Validate_Interface $validator * @param bool $breakChainOnFailure - * @param array $options + * @param array $options * @return Zend_Form_Element * @throws Zend_Form_Exception if invalid validator type */ @@ -1103,8 +1104,8 @@ /** * Add multiple validators - * - * @param array $validators + * + * @param array $validators * @return Zend_Form_Element */ public function addValidators(array $validators) @@ -1153,8 +1154,8 @@ /** * Set multiple validators, overwriting previous validators - * - * @param array $validators + * + * @param array $validators * @return Zend_Form_Element */ public function setValidators(array $validators) @@ -1165,8 +1166,8 @@ /** * Retrieve a single validator by name - * - * @param string $name + * + * @param string $name * @return Zend_Validate_Interface|false False if not found, validator otherwise */ public function getValidator($name) @@ -1196,7 +1197,7 @@ /** * Retrieve all validators - * + * * @return array */ public function getValidators() @@ -1215,8 +1216,8 @@ /** * Remove a single validator by name - * - * @param string $name + * + * @param string $name * @return bool */ public function removeValidator($name) @@ -1241,7 +1242,7 @@ /** * Clear all validators - * + * * @return Zend_Form_Element */ public function clearValidators() @@ -1253,15 +1254,15 @@ /** * Validate element value * - * If a translation adapter is registered, any error messages will be - * translated according to the current locale, using the given error code; - * if no matching translation is found, the original message will be + * If a translation adapter is registered, any error messages will be + * translated according to the current locale, using the given error code; + * if no matching translation is found, the original message will be * utilized. * * Note: The *filtered* value is validated. - * - * @param mixed $value - * @param mixed $context + * + * @param mixed $value + * @param mixed $context * @return boolean */ public function isValid($value, $context = null) @@ -1269,15 +1270,15 @@ $this->setValue($value); $value = $this->getValue(); - if ((('' === $value) || (null === $value)) - && !$this->isRequired() + if ((('' === $value) || (null === $value)) + && !$this->isRequired() && $this->getAllowEmpty() ) { return true; } - if ($this->isRequired() - && $this->autoInsertNotEmptyValidator() + if ($this->isRequired() + && $this->autoInsertNotEmptyValidator() && !$this->getValidator('NotEmpty')) { $validators = $this->getValidators(); @@ -1341,8 +1342,8 @@ /** * Add a custom error message to return in the event of failed validation - * - * @param string $message + * + * @param string $message * @return Zend_Form_Element */ public function addErrorMessage($message) @@ -1353,8 +1354,8 @@ /** * Add multiple custom error messages to return in the event of failed validation - * - * @param array $messages + * + * @param array $messages * @return Zend_Form_Element */ public function addErrorMessages(array $messages) @@ -1367,8 +1368,8 @@ /** * Same as addErrorMessages(), but clears custom error message stack first - * - * @param array $messages + * + * @param array $messages * @return Zend_Form_Element */ public function setErrorMessages(array $messages) @@ -1379,7 +1380,7 @@ /** * Retrieve custom error messages - * + * * @return array */ public function getErrorMessages() @@ -1389,7 +1390,7 @@ /** * Clear custom error messages stack - * + * * @return Zend_Form_Element */ public function clearErrorMessages() @@ -1400,7 +1401,7 @@ /** * Mark the element as being in a failed validation state - * + * * @return Zend_Form_Element */ public function markAsError() @@ -1418,8 +1419,8 @@ /** * Add an error message and mark element as failed validation - * - * @param string $message + * + * @param string $message * @return Zend_Form_Element */ public function addError($message) @@ -1431,8 +1432,8 @@ /** * Add multiple error messages and flag element as failed validation - * - * @param array $messages + * + * @param array $messages * @return Zend_Form_Element */ public function addErrors(array $messages) @@ -1445,8 +1446,8 @@ /** * Overwrite any previously set error messages and flag as failed validation - * - * @param array $messages + * + * @param array $messages * @return Zend_Form_Element */ public function setErrors(array $messages) @@ -1457,7 +1458,7 @@ /** * Are there errors registered? - * + * * @return bool */ public function hasErrors() @@ -1467,7 +1468,7 @@ /** * Retrieve validator chain errors - * + * * @return array */ public function getErrors() @@ -1477,7 +1478,7 @@ /** * Retrieve error messages - * + * * @return array */ public function getMessages() @@ -1490,8 +1491,8 @@ /** * Add a filter to the element - * - * @param string|Zend_Filter_Interface $filter + * + * @param string|Zend_Filter_Interface $filter * @return Zend_Form_Element */ public function addFilter($filter, $options = array()) @@ -1501,7 +1502,7 @@ } elseif (is_string($filter)) { $name = $filter; $filter = array( - 'filter' => $filter, + 'filter' => $filter, 'options' => $options, ); $this->_filters[$name] = $filter; @@ -1517,8 +1518,8 @@ /** * Add filters to element - * - * @param array $filters + * + * @param array $filters * @return Zend_Form_Element */ public function addFilters(array $filters) @@ -1561,8 +1562,8 @@ /** * Add filters to element, overwriting any already existing - * - * @param array $filters + * + * @param array $filters * @return Zend_Form_Element */ public function setFilters(array $filters) @@ -1573,8 +1574,8 @@ /** * Retrieve a single filter by name - * - * @param string $name + * + * @param string $name * @return Zend_Filter_Interface */ public function getFilter($name) @@ -1605,7 +1606,7 @@ /** * Get all filters - * + * * @return array */ public function getFilters() @@ -1624,8 +1625,8 @@ /** * Remove a filter by name - * - * @param string $name + * + * @param string $name * @return Zend_Form_Element */ public function removeFilter($name) @@ -1650,7 +1651,7 @@ /** * Clear all filters - * + * * @return Zend_Form_Element */ public function clearFilters() @@ -1663,8 +1664,8 @@ /** * Set view object - * - * @param Zend_View_Interface $view + * + * @param Zend_View_Interface $view * @return Zend_Form_Element */ public function setView(Zend_View_Interface $view = null) @@ -1677,7 +1678,7 @@ * Retrieve view object * * Retrieves from ViewRenderer if none previously set. - * + * * @return null|Zend_View_Interface */ public function getView() @@ -1692,9 +1693,9 @@ /** * Instantiate a decorator based on class name or class name fragment - * - * @param string $name - * @param null|array $options + * + * @param string $name + * @param null|array $options * @return Zend_Form_Decorator_Interface */ protected function _getDecorator($name, $options) @@ -1711,8 +1712,8 @@ /** * Add a decorator for rendering the element - * - * @param string|Zend_Form_Decorator_Interface $decorator + * + * @param string|Zend_Form_Decorator_Interface $decorator * @param array|Zend_Config $options Options with which to initialize decorator * @return Zend_Form_Element */ @@ -1754,8 +1755,8 @@ /** * Add many decorators at once - * - * @param array $decorators + * + * @param array $decorators * @return Zend_Form_Element */ public function addDecorators(array $decorators) @@ -1798,8 +1799,8 @@ /** * Overwrite all decorators - * - * @param array $decorators + * + * @param array $decorators * @return Zend_Form_Element */ public function setDecorators(array $decorators) @@ -1810,8 +1811,8 @@ /** * Retrieve a registered decorator - * - * @param string $name + * + * @param string $name * @return false|Zend_Form_Decorator_Abstract */ public function getDecorator($name) @@ -1842,7 +1843,7 @@ /** * Retrieve all decorators - * + * * @return array */ public function getDecorators() @@ -1857,8 +1858,8 @@ /** * Remove a single decorator - * - * @param string $name + * + * @param string $name * @return bool */ public function removeDecorator($name) @@ -1883,7 +1884,7 @@ /** * Clear all decorators - * + * * @return Zend_Form_Element */ public function clearDecorators() @@ -1894,8 +1895,8 @@ /** * Render form element - * - * @param Zend_View_Interface $view + * + * @param Zend_View_Interface $view * @return string */ public function render(Zend_View_Interface $view = null) @@ -1916,7 +1917,7 @@ * String representation of form element * * Proxies to {@link render()}. - * + * * @return string */ public function __toString() @@ -1932,8 +1933,8 @@ /** * Lazy-load a filter - * - * @param array $filter + * + * @param array $filter * @return Zend_Filter_Interface */ protected function _loadFilter(array $filter) @@ -1981,7 +1982,7 @@ /** * Lazy-load a validator - * + * * @param array $validator Validator definition * @return Zend_Validate_Interface */ @@ -2046,7 +2047,7 @@ /** * Lazy-load a decorator - * + * * @param array $decorator Decorator type and options * @param mixed $name Decorator name or alias * @return Zend_Form_Decorator_Interface @@ -2084,7 +2085,7 @@ /** * Retrieve error messages and perform translation and value substitution - * + * * @return array */ protected function _getErrorMessages() @@ -2111,7 +2112,7 @@ /** * Are there custom error messages registered? - * + * * @return bool */ protected function _hasErrorMessages() Index: library/Zend/Form/Decorator/Label.php =================================================================== --- library/Zend/Form/Decorator/Label.php (revision 13576) +++ library/Zend/Form/Decorator/Label.php (working copy) @@ -35,7 +35,7 @@ * - req(uired)Suffix: a suffix to the label to use when the element is required * * Any other options passed will be used as HTML attributes of the label tag. - * + * * @category Zend * @package Zend_Form * @subpackage Decorator @@ -59,8 +59,8 @@ /** * Set element ID - * - * @param string $id + * + * @param string $id * @return Zend_Form_Decorator_Label */ public function setId($id) @@ -72,9 +72,9 @@ /** * Retrieve element ID (used in 'for' attribute) * - * If none set in decorator, looks first for element 'id' attribute, and + * If none set in decorator, looks first for element 'id' attribute, and * defaults to element name. - * + * * @return string */ public function getId() @@ -92,8 +92,8 @@ /** * Set HTML tag with which to surround label - * - * @param string $tag + * + * @param string $tag * @return Zend_Form_Decorator_Label */ public function setTag($tag) @@ -108,7 +108,7 @@ /** * Get HTML tag, if any, with which to surround label - * + * * @return void */ public function getTag() @@ -128,9 +128,9 @@ /** * Get class with which to define label * - * Appends either 'optional' or 'required' to class, depending on whether + * Appends either 'optional' or 'required' to class, depending on whether * or not the element is required. - * + * * @return string */ public function getClass() @@ -155,8 +155,8 @@ /** * Load an optional/required suffix/prefix key - * - * @param string $key + * + * @param string $key * @return void */ protected function _loadOptReqKey($key) @@ -183,9 +183,9 @@ * - setOpt(ional)Suffix() * - setReq(uired)Prefix() * - setReq(uired)Suffix() - * - * @param string $method - * @param array $args + * + * @param string $method + * @param array $args * @return mixed * @throws Zend_Form_Exception for unsupported methods */ @@ -238,7 +238,7 @@ /** * Get label to render - * + * * @return void */ public function getLabel() @@ -278,8 +278,8 @@ /** * Render a label - * - * @param string $content + * + * @param string $content * @return string */ public function render($content) @@ -305,7 +305,7 @@ if (!empty($label)) { $options['class'] = $class; - $label = $view->formLabel($element->getFullyQualifiedName(), trim($label), $options); + $label = $view->formLabel($element->getFullyQualifiedName(), trim($label), $options); } else { $label = ' '; } @@ -313,7 +313,8 @@ if (null !== $tag) { require_once 'Zend/Form/Decorator/HtmlTag.php'; $decorator = new Zend_Form_Decorator_HtmlTag(); - $decorator->setOptions(array('tag' => $tag)); + $decorator->setOptions(array('tag' => $tag, + 'id' => $element->getName() . '-label')); $label = $decorator->render($label); } Index: library/Zend/Form/Decorator/DtDdWrapper.php =================================================================== --- library/Zend/Form/Decorator/DtDdWrapper.php (revision 13576) +++ library/Zend/Form/Decorator/DtDdWrapper.php (working copy) @@ -25,9 +25,9 @@ /** * Zend_Form_Decorator_DtDdWrapper * - * Creates an empty