mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02: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:
@@ -1,4 +1,7 @@
|
|||||||
===== trunk =====
|
===== trunk =====
|
||||||
|
13.11.2012
|
||||||
|
- 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)
|
||||||
|
|
||||||
01.11.2012
|
01.11.2012
|
||||||
- bugfix muteExcpetedErrors() would screw up for non-readable paths (Issue #118)
|
- bugfix muteExcpetedErrors() would screw up for non-readable paths (Issue #118)
|
||||||
|
|
||||||
|
@@ -116,6 +116,23 @@ function smarty_function_html_checkboxes($params, $template)
|
|||||||
case 'assign':
|
case 'assign':
|
||||||
break;
|
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:
|
default:
|
||||||
if(!is_array($_val)) {
|
if(!is_array($_val)) {
|
||||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
||||||
|
@@ -90,7 +90,24 @@ function smarty_function_html_options($params, $template)
|
|||||||
$selected = smarty_function_escape_special_chars((string) $_val);
|
$selected = smarty_function_escape_special_chars((string) $_val);
|
||||||
}
|
}
|
||||||
break;
|
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:
|
default:
|
||||||
if (!is_array($_val)) {
|
if (!is_array($_val)) {
|
||||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||||
|
@@ -102,6 +102,23 @@ function smarty_function_html_radios($params, $template)
|
|||||||
case 'assign':
|
case 'assign':
|
||||||
break;
|
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:
|
default:
|
||||||
if (!is_array($_val)) {
|
if (!is_array($_val)) {
|
||||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||||
|
Reference in New Issue
Block a user