mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-02 13:21:36 +01:00
- adding attribute "strict" to html_options, html_checkboxes, html_radios to only print disabled/readonly attributes if their values are true or "disabled"/"readonly" (Issue #120)
This commit is contained in:
@@ -90,7 +90,24 @@ function smarty_function_html_options($params, $template)
|
||||
$selected = smarty_function_escape_special_chars((string) $_val);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'strict': break;
|
||||
|
||||
case 'disabled':
|
||||
case 'readonly':
|
||||
if (!empty($params['strict'])) {
|
||||
if (!is_scalar($_val)) {
|
||||
trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", E_USER_NOTICE);
|
||||
}
|
||||
|
||||
if ($_val === true || $_val === $_key) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
// omit break; to fall through!
|
||||
|
||||
default:
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||
|
||||
Reference in New Issue
Block a user