Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.3.13

Bug #15272 Checkboxes with arrays get wrong names and attributes with flexy:nameuses
Submitted: 2008-12-08 02:50 UTC
From: heikkiu Assigned: alan_k
Status: Closed Package: HTML_Template_Flexy (version 1.3.4)
PHP Version: 5.2.5 OS:
Roadmaps: (Not assigned)    
Subscription  


 [2008-12-08 02:50 UTC] heikkiu (Heikki Uusitalo)
Description: ------------ Checkboxes with arrays get their values and attributes wrong with flexy:nameuses. An attribute or a value that is set in the template gets copied down to all the remaining members of the group. This is due to an error in the mechanism that the compiled template uses to store data. Please note that this bug is independent of http://pear.php.net/bugs/bug.php?id=15263 Test script: --------------- ---------- TEMPLATE:
foo bar
---------- TEST CLASS: class foo { var $twomembers=array( 'this is number zero', 'this is number two', ); function __construct() { require_once ("HTML/Template/Flexy.php"); $flexy=new HTML_Template_Flexy($options); //options omitted $flexy->compile("testCase.template.html"); $flexy->outputObject($this); } } new foo; Expected result: ----------------
foo bar
foo bar
Actual result: --------------
foo bar
foo bar
</form>

Comments

 [2008-12-08 02:56 UTC] heikkiu (Heikki Uusitalo)
My expected result was overtly pessimistic :) I would expect the checkbox that has the text "bar" after it to have the value "bar" as in the template. This bug is rather serious, since it also affects the value attribute. This is the real EXPECTED RESULT:
foo bar
foo bar
</form>
 [2008-12-09 15:17 UTC] heikkiu (Heikki Uusitalo)
This bug happens because the compiled template overwrites $this->elements when getting the values for dynamic elements, so when we reach a second element, the defaults are wrong. I've uploaded a patch that modifies the Tag.php compiler so that when dealing with dynamic elements, the values of $this->elements are not modified. We're using a temporary var $element instead. I've also added a check in the "mergeWithName" part, which was trying to get its defaults from $this->elements[''] if no name was set.
 [2009-03-02 13:09 UTC] alan_k (Alan Knowles)
-Status: Open +Status: Closed -Assigned To: +Assigned To: alan_k
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.