Fixed issue where $selected = true sent to FormHelper date method was generating multiple OPTION tags with SELECTED attribute

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6746 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2008-05-01 21:26:11 +00:00
parent 893c218be6
commit e0a9f03572

View file

@ -1107,7 +1107,7 @@ class FormHelper extends AppHelper {
* @return string * @return string
*/ */
function day($fieldName, $selected = null, $attributes = array(), $showEmpty = true) { function day($fieldName, $selected = null, $attributes = array(), $showEmpty = true) {
if (empty($selected) && $value = $this->value($fieldName)) { if ((empty($selected) || $selected === true) && $value = $this->value($fieldName)) {
if (is_array($value)) { if (is_array($value)) {
extract($value); extract($value);
$selected = $day; $selected = $day;
@ -1141,7 +1141,7 @@ class FormHelper extends AppHelper {
* @return string * @return string
*/ */
function year($fieldName, $minYear = null, $maxYear = null, $selected = null, $attributes = array(), $showEmpty = true) { function year($fieldName, $minYear = null, $maxYear = null, $selected = null, $attributes = array(), $showEmpty = true) {
if (empty($selected) && $value = $this->value($fieldName)) { if ((empty($selected) || $selected === true) && $value = $this->value($fieldName)) {
if (is_array($value)) { if (is_array($value)) {
extract($value); extract($value);
$selected = $year; $selected = $year;
@ -1176,7 +1176,7 @@ class FormHelper extends AppHelper {
* @return string * @return string
*/ */
function month($fieldName, $selected = null, $attributes = array(), $showEmpty = true) { function month($fieldName, $selected = null, $attributes = array(), $showEmpty = true) {
if (empty($selected) && $value = $this->value($fieldName)) { if ((empty($selected) || $selected === true) && $value = $this->value($fieldName)) {
if (is_array($value)) { if (is_array($value)) {
extract($value); extract($value);
$selected = $month; $selected = $month;
@ -1209,7 +1209,7 @@ class FormHelper extends AppHelper {
* @return string * @return string
*/ */
function hour($fieldName, $format24Hours = false, $selected = null, $attributes = array(), $showEmpty = true) { function hour($fieldName, $format24Hours = false, $selected = null, $attributes = array(), $showEmpty = true) {
if (empty($selected) && $value = $this->value($fieldName)) { if ((empty($selected) || $selected === true) && $value = $this->value($fieldName)) {
if (is_array($value)) { if (is_array($value)) {
extract($value); extract($value);
$selected = $hour; $selected = $hour;
@ -1243,7 +1243,7 @@ class FormHelper extends AppHelper {
* @return string * @return string
*/ */
function minute($fieldName, $selected = null, $attributes = array(), $showEmpty = true) { function minute($fieldName, $selected = null, $attributes = array(), $showEmpty = true) {
if (empty($selected) && $value = $this->value($fieldName)) { if ((empty($selected) || $selected === true) && $value = $this->value($fieldName)) {
if (is_array($value)) { if (is_array($value)) {
extract($value); extract($value);
$selected = $min; $selected = $min;
@ -1279,7 +1279,7 @@ class FormHelper extends AppHelper {
* @return string * @return string
*/ */
function meridian($fieldName, $selected = null, $attributes = array(), $showEmpty = true) { function meridian($fieldName, $selected = null, $attributes = array(), $showEmpty = true) {
if (empty($selected) && $value = $this->value($fieldName)) { if ((empty($selected) || $selected === true) && $value = $this->value($fieldName)) {
if (is_array($value)) { if (is_array($value)) {
extract($value); extract($value);
$selected = $meridian; $selected = $meridian;