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

Bug #5364 Date Element: addEmptyOption still buggy
Submitted: 2005-09-12 10:35 UTC
From: tomni Assigned: avb
Status: Closed Package: HTML_QuickForm
PHP Version: 5.0.5 OS: Suse Linux 9.1
Roadmaps: (Not assigned)    
Subscription  


 [2005-09-12 10:35 UTC] tomni
Description: ------------ This isnt right now working cause there is a bug in the option list parsing code. If you try to set it to an array like array('format char' => true, 'format char' = false) the array is getting lost in the HTML_QuickForm_data() function in line 276 of the date.php file. The reason is because the array_merge isnt working cause the first parameter ($this->_options[$name]) is not an array. Therefor you get a error message after removing the "@" in front of it. ------------------------------------------------------- This is the PHP Error Message -- Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /usr/local/apache/share/php/HTML/QuickForm/date.php on line 276 Test script: --------------- nothing to post in here Expected result: ---------------- That the array is correctly getting processed Actual result: -------------- After setting the addEmptyOption to an array it loses the setting and therefor its ignored in the final stage where the empty fields should be added on top of the select box.

Comments

 [2006-05-05 03:53 UTC] akkun_choi at hotmail dot com (Akiyoshi Tanaka)
addEmptyOption/emptyOptionText still doesnt work when give it array at my environment WinXP. I think it should be like following to preserve the keys of array. date.php line 270 - $this->_options[$name] = @array_merge($this->_options[$name], $value); + $this->_options[$name] = (array)$this->_options[$name] + $value;
 [2006-05-18 15:56 UTC] brianpap22 at yahoo dot com (Brian)
Confirmed here: PHP 5.1.2-gentoo (cli) (built: Apr 12 2006 21:09:43) HTML_QuickForm version: 3.2.5 In my code, I have the following: $date_options = array( 'language' => 'en', 'format' => 'dMY', 'maxYear' => 1900, 'minYear' => date('Y'), 'addEmptyOption' => array('d' => true, 'M' => true, 'Y' => true), 'emptyOptionValue'=> '', 'emptyOptionText' => array('d' => 'Day', 'M' => 'Month', 'Y' => 'Year') ); $form->addElement('date', 'dob', 'DOB:', $date_options); But the addEmptyOption has no effect on the final output if it is an array. It was getting lost on line 270 of date.php because of the array merge. To confirm this, I went to lines 76-78 of date.php and changed the hard-coded defaults from: 'addEmptyOption' => false, 'emptyOptionValue' => '', 'emptyOptionText' => ' ', to: 'addEmptyOption' => array('d' => true, 'M' => true, 'Y' => true), 'emptyOptionValue'=> '', 'emptyOptionText' => array('d' => 'Day', 'M' => 'Month', 'Y' => 'Year'), And it works perfectly! Hence, bug confirmed, and the solution proposed by Akiyoshi fixes this. Please update QuickForm!
 [2006-06-03 12:33 UTC] avb (Alexey Borzov)
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.