PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » HTML_QuickForm » Bug #213

HTML Element and Array Renderer

Details

Submitted2003-11-07 12:54 UTC
Fromltransom at yahoo dot com
StatusBogus
PackageHTML_QuickForm
PHP Version4.3.2
OSLinux
Roadmaps(Not assigned)

Comments

[2003-11-07 12:54 UTC] ltransom at yahoo dot com

Description:
------------
The HTML element overrides the 'accept' method of its base class 'element'. This precludes use with other renderers such as the array renderer. In the snippet below, the HTML elements are not included in the array output.

Reproduce code:
---------------
$this->form = new HTML_QuickForm(SOMEFORM_NAME);
$this->form->addElement('header', null, 'Some Form');

//... add various other elements ...

$this->form->addElement('html','<tr><td colspan="2" class="DataTS"><table>');

//... add more elements ...

$this->form->addElement('html','</table></td></tr>');

$tpl->assign('form', $this->form->toArray()); // $tpl is Smarty

Expected result:
----------------
I confess that I have not looked at the internals of the code to know the impact of my change with other renderers, but in my own code I simply removed the 'accept' override in the HTML class. That change outputs the HTML element in the array with the other elements, as expected.

I use the array renderer as input into Smarty. I use the HTML element for some fairly advanced form layout. (it also happens to be dynamic)

[2004-11-05 16:46 UTC] jmf at dyingculture dot net

I also think that this feature is lacking. ArraySmarty renderer is not suitable for every purpose. For example, I use the same Smarty template for all my forms because it is very handy for maintenance. This way, I can not insert static HTML directly into the template because I only need this HTML in one page whereas the form template is used in N pages.

The HTML element is the solution to this problem. So here is a very simple patch to the Array.php file :

This very simple function adds this feature to the Array renderer :

/**
* Called when visiting a raw HTML/text pseudo-element
*
* @param object An HTML_QuickForm_html element being visited
* @access public
* @return void
*/
function renderHtml(&$element)
{
$this->renderElement($element, false, false);
} // end func renderHtml

With this, the HTML elements are rendered with the Array renderer.

[2004-11-25 16:19 UTC] jmf at dyingculture dot net

I can not find any notice of the "html" element being deprecated neither in the official documentation, neither in the latest release sources.

Moreover, as this element is very useful in some cases, will it be replaced or will it just be dropped ?

[2005-11-28 20:07 UTC] stefan at farsite dot de

I would also agree that the "html" element type is quite useful in use with the Array-renderer and Smarty.

I do have some reasonably complex forms which I designed with QF-controller. Now, I do not want to create a template with ArraySmarty for each page of my wizard since the only few things I'd like to add are dividers and likes between some elements.

So, I do encourage you to reconsider your judgement of this element. For now, I might use the posted "patch" since it seems to be the only way to get what I need.

Anyhow, thank you so much for this excellent tool.

Greets, Stefan