Skip to content

Commit

Permalink
Fixes #2921
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgutierrez committed Jun 5, 2015
1 parent c28a267 commit c9d7906
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 50 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Added an option to return the SQL to be generated from a Mvc\Model\Query instance (#1908)
- Fix doesn't correct column domain in `Phalcon\Db\Dialect::select()` see [#10439](https://github.com/phalcon/cphalcon/pull/10439)
- Added support for DOUBLE type in MySQL
- Phalcon\Tag\Select now handles array values as strings avoiding that zero will be handled as empty string (#2921)

# 2.0.2 (2015-05-26)
- Added `stats()` methods to Beanstalk
Expand Down
98 changes: 54 additions & 44 deletions ext/phalcon/tag/select.zep.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 15 additions & 6 deletions phalcon/tag/select.zep
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ abstract class Select
*/
private static function _optionsFromResultset(resultset, using, value, closeOption)
{
var code, params, option, usingZero, usingOne, optionValue, optionText;
var code, params, option, usingZero, usingOne,
optionValue, optionText, strValue, strOptionValue;

let code = "";
let params = null;
Expand Down Expand Up @@ -194,7 +195,9 @@ abstract class Select
let code .= "\t<option value=\"" . optionValue . "\">" . optionText . closeOption;
}
} else {
if optionValue == value {
let strOptionValue = (string) optionValue,
strValue = (string) value;
if strOptionValue === strValue {
let code .= "\t<option selected=\"selected\" value=\"" . optionValue . "\">" . optionText . closeOption;
} else {
let code .= "\t<option value=\"" . optionValue . "\">" . optionText . closeOption;
Expand Down Expand Up @@ -227,11 +230,16 @@ abstract class Select
*/
private static function _optionsFromArray(data, value, closeOption)
{
var code, optionValue, optionText, escaped;
var strValue, strOptionValue, code, optionValue, optionText, escaped;

let code = "",
strValue = (string) value;

let code = "";
for optionValue, optionText in data {
let escaped = htmlspecialchars(optionValue);

let strOptionValue = (string) optionValue,
escaped = htmlspecialchars(optionValue);

if typeof optionText == "array" {
let code .= "\t<optgroup label=\"" . escaped . "\">" . PHP_EOL . self::_optionsFromArray(optionText, value, closeOption) . "\t</optgroup>" . PHP_EOL;
} else {
Expand All @@ -242,14 +250,15 @@ abstract class Select
let code .= "\t<option value=\"" . escaped . "\">" . optionText . closeOption;
}
} else {
if optionValue == value {
if strOptionValue === strValue {
let code .= "\t<option selected=\"selected\" value=\"" . escaped . "\">" . optionText . closeOption;
} else {
let code .= "\t<option value=\"" . escaped . "\">" . optionText . closeOption;
}
}
}
}

return code;
}
}

0 comments on commit c9d7906

Please sign in to comment.