Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: POC fix for dev/core#5571. #416

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
WIP: POC fix for dev/core#5571.
twomice committed Nov 6, 2024
commit 5de6f943a753381e4223347c68780b45f9a97e08
14 changes: 11 additions & 3 deletions HTML/QuickForm/Renderer/ArraySmarty.php
Original file line number Diff line number Diff line change
@@ -197,7 +197,7 @@ function _elementToArray(&$element, $required, $error)
$this->_renderRequired($ret['label'], $ret['html'], $required, $error);
}
if ($error && !empty($this->_error)) {
$this->_renderError($ret['label'], $ret['html'], $error);
$this->_renderError($ret['label'], $ret['html'], $error, $element->_type);
$ret['error'] = $error;
}
// create keys for elements grouped by native group or name
@@ -310,11 +310,12 @@ function _renderRequired(&$label, &$html, &$required, &$error)
* @param string The element label
* @param string The element html rendering
* @param string The element error
* @param string Type of the relevant quickform element
* @see setErrorTemplate()
* @access private
* @return void
*/
function _renderError(&$label, &$html, &$error)
function _renderError(&$label, &$html, &$error, $elementType)
{
$this->_tpl->assign(array('label' => '', 'html' => '', 'error' => $error));
$error = $this->_tplFetch($this->_error);
@@ -323,7 +324,14 @@ function _renderError(&$label, &$html, &$error)
if (!empty($label) && strpos($this->_error, $this->_tpl->left_delimiter . '$label') !== false) {
$label = $this->_tplFetch($this->_error);
} elseif (!empty($html) && strpos($this->_error, $this->_tpl->left_delimiter . '$html') !== false) {
$html = $this->_tplFetch($this->_error);
// Fix dev/core#5571: For 'group'-type elements (checkboxes/radios), merely display $error;
// for other types, re-render the error template completely.
if ($elementType == 'group') {
$html = $error;
}
else {
$html = $this->_tplFetch($this->_error);
}
}
$this->_tpl->clear_assign(array('label', 'html', 'error'));
} // end func _renderError