Skip to content

Commit

Permalink
- Bug #15301: JavaScript errors occured if addGroupRule() was used in
Browse files Browse the repository at this point in the history
  the short notation (i.e. a general rule like 'required' for all group
  elements, and not rules for single elements of a group)
  (thanks to Gery Flament)


git-svn-id: http://svn.php.net/repository/pear/packages/HTML_QuickForm_DHTMLRulesTableless/trunk@271935 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Mark Wiesemann committed Dec 26, 2008
1 parent 7cde7e0 commit bfcbc30
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
7 changes: 6 additions & 1 deletion HTML/QuickForm/DHTMLRulesTableless.php
Expand Up @@ -239,7 +239,12 @@ function getValidationScript()
$element =& $this->getElement($singleElementName);
$elementNameForJS = 'frm.elements[\'' . $elementName . '\']';
if ($element->getType() === 'group' && $singleElementName === $elementName) {
$elementNameForJS = 'document.getElementById(\'' . $element->_elements[0]->getAttribute('id') . '\')';
$firstFieldId = $element->_elements[0]->getAttribute('id');
if ($firstFieldId) {
$elementNameForJS = 'document.getElementById(\'' . $firstFieldId . '\')';
} else {
$elementNameForJS = 'frm.elements[\'' . $element->getElementName(0) . '\']';
}
}
$validateJS .= '
ret = validate_' . $id . '_' . $shortNameForJS . '('. $elementNameForJS . ') && ret;';
Expand Down
7 changes: 6 additions & 1 deletion HTML/QuickForm/PageDHTMLRulesTableless.php
Expand Up @@ -251,7 +251,12 @@ function getValidationScript()
$element =& $this->getElement($singleElementName);
$elementNameForJS = 'frm.elements[\'' . $elementName . '\']';
if ($element->getType() === 'group' && $singleElementName === $elementName) {
$elementNameForJS = 'document.getElementById(\'' . $element->_elements[0]->getAttribute('id') . '\')';
$firstFieldId = $element->_elements[0]->getAttribute('id');
if ($firstFieldId) {
$elementNameForJS = 'document.getElementById(\'' . $firstFieldId . '\')';
} else {
$elementNameForJS = 'frm.elements[\'' . $element->getElementName(0) . '\']';
}
}
$validateJS .= '
ret = validate_' . $id . '_' . $shortNameForJS . '('. $elementNameForJS . ') && ret;';
Expand Down
6 changes: 4 additions & 2 deletions package2.xml
Expand Up @@ -31,8 +31,10 @@ http://pear.php.net/dtd/package-2.0.xsd">
</stability>
<license>New BSD</license>
<notes>
- Bug #12166: form names containing dashes ('-') caused JavaScript errors
(thanks to Jeff MacDonald)
- Bug #15301: JavaScript errors occured if addGroupRule() was used in
the short notation (i.e. a general rule like 'required' for all group
elements, and not rules for single elements of a group)
(thanks to Gery Flament)
</notes>
<contents>
<dir name="/">
Expand Down

0 comments on commit bfcbc30

Please sign in to comment.