Bug in HTML::QuickForm when frozen / validity of HTML

From: Date: Mon, 30 Sep 2002 15:56:46 +0000
Subject: Bug in HTML::QuickForm when frozen / validity of HTML
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-9719@lists.php.net to get a copy of this message
Hi, I found the following bug in HTML::QuickForm: if you create a form with validation rules and then freeze it, the generated HTML includes an onsubmit attribute which refers to the validation script, but the script is not generated. This causes a javascript error. I have a fix which works for my use of the class but has not been tested more generally and may anyway not be the best solution. The following lines are inserted at the start of the _wrapForm() method (line 1029 in v.1.38):- if($this->_freezeAll) { unset($this->_attributes['onsubmit']); } Also, the default form template puts the form inside the table which is invalid HTML. This can easily be fixed by a simple edit to the template, but the HTML generated for hidden elements is more tricky. They are not generated inside <tr> and <td> tags presumably to avoid them using screenspace, but this means they break the structure rules for <table> elements. I have tested putting them inside <tr> and <td> tags, and in the browsers I tried (IE 5.5 and Mozilla 1.1) there is very little visible effect, so this might be the easiest approach, if other browsers behave in the same way. (A better alternative might be to handle hidden content separately, but this would require more coding effort). My simple fix is to change the following line found in method _buildElement (line 1087 in v 1.38) from: $html = "\n" . $this->_getTabs() . "\t" . $object->toHtml(); to: $html = "\n<tr><td>" . $object->toHtml()."</td></tr>"; Nigel Armstrong Tertio Service Management Solutions Limited, 338-346 Goswell Road, London EC1V 7LQ Tel: 020 7239 0600 Fax: 020 7239 0500 Email: info@tertio.com Web: http://www.sms-tertio.com Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Tertio Service Management Solutions Ltd.

« previous php.pear.dev (#9719) next »