Home » HTML » HTML_QuickForm » Bug #1516
No use of separators when setGroupTemplate
Details
| Submitted | 2004-05-27 12:48 UTC |
|---|---|
| From | ths at php dot net |
| Assigned | avb |
| Status | Closed |
| Package | HTML_QuickForm |
| PHP Version | Irrelevant |
| OS | WinXP |
| Roadmaps | (Not assigned) |
Comments
[2004-05-27 12:48 UTC] ths at php dot net
Description:
------------
On using setGroupTemplate() the separators from addGroup() have no effect.
Here is the fixed method finishGroup in Renderer/Default.php. Sorry for not providing a diff, but Default.php is unfortunally binary in CVS.
/**
* Called when visiting a group, after processing all group elements
*
* @param object An HTML_QuickForm_group object being visited
* @access public
* @return void
*/
function finishGroup(&$group)
{
$separator = $group->_separator;
if (is_array($separator)) {
$count = count($separator);
$html = '';
for ($i = 0; $i < count($this->_groupElements); $i++) {
$html .= (0 == $i? '': $separator[($i - 1) % $count]) . $this->_groupElements[$i];
}
} else {
if (is_null($separator)) {
$separator = ' ';
if (!empty($this->_groupWrap)) {
$separator = '';
}
}
$html = implode((string)$separator, $this->_groupElements);
}
if (!empty($this->_groupWrap)) {
$html = str_replace('{content}', $html, $this->_groupWrap);
}
$this->_html .= str_replace('{element}', $html, $this->_groupTemplate);
$this->_inGroup = false;
} // end func finishGroup
Reproduce code:
---------------
require_once 'HTML/QuickForm.php';
$form =& new HTML_QuickForm('frmGroups');
$renderer =& $form->defaultRenderer();
// Setting special template for group element
$renderer->setGroupTemplate('<table border="1"><tr>{content}</tr></table>', 'group');
$renderer->setGroupElementTemplate('<td>{element}</td>', 'group');
// Creates a checkboxes group using an array of separators
$boxes = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H');
foreach ($boxes as $box) {
$checkbox[] = &HTML_QuickForm::createElement('checkbox', $box, null, $box);
}
$form->addGroup($checkbox, 'group', 'ABC...', array ('', '', '', '</tr><tr>'));
$form->display();
Expected result:
----------------
New table row after the 4. element.
Actual result:
--------------
The separators have no effect.