mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 19:04:27 +02:00
make form input label ids optional (monte)
This commit is contained in:
1
NEWS
1
NEWS
@@ -1,3 +1,4 @@
|
|||||||
|
- make form input label ids optional (monte)
|
||||||
- add error message for empty if/elseif statements (eykanal,
|
- add error message for empty if/elseif statements (eykanal,
|
||||||
monte)
|
monte)
|
||||||
- cast selected value to string for comparison in html_radios
|
- cast selected value to string for comparison in html_radios
|
||||||
|
@@ -48,6 +48,7 @@ function smarty_function_html_radios($params, &$smarty)
|
|||||||
$selected = null;
|
$selected = null;
|
||||||
$separator = '';
|
$separator = '';
|
||||||
$labels = true;
|
$labels = true;
|
||||||
|
$label_ids = false;
|
||||||
$output = null;
|
$output = null;
|
||||||
$extra = '';
|
$extra = '';
|
||||||
|
|
||||||
@@ -68,6 +69,7 @@ function smarty_function_html_radios($params, &$smarty)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'labels':
|
case 'labels':
|
||||||
|
case 'label_ids':
|
||||||
$$_key = (bool)$_val;
|
$$_key = (bool)$_val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -106,13 +108,13 @@ function smarty_function_html_radios($params, &$smarty)
|
|||||||
if (isset($options)) {
|
if (isset($options)) {
|
||||||
|
|
||||||
foreach ($options as $_key=>$_val)
|
foreach ($options as $_key=>$_val)
|
||||||
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
|
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
foreach ($values as $_i=>$_key) {
|
foreach ($values as $_i=>$_key) {
|
||||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
||||||
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
|
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -125,17 +127,21 @@ function smarty_function_html_radios($params, &$smarty)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels) {
|
function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids) {
|
||||||
$_output = '';
|
$_output = '';
|
||||||
if ($labels) {
|
if ($labels) {
|
||||||
$_id = smarty_function_escape_special_chars($name . '_' . $value);
|
if($label_ids) {
|
||||||
$_output .= '<label for="' . $_id . '">';
|
$_id = smarty_function_escape_special_chars(str_replace(' ', '_', $name . '_' . $value));
|
||||||
|
$_output .= '<label for="' . $_id . '">';
|
||||||
|
} else {
|
||||||
|
$_output .= '<label>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$_output .= '<input type="radio" name="'
|
$_output .= '<input type="radio" name="'
|
||||||
. smarty_function_escape_special_chars($name) . '" value="'
|
. smarty_function_escape_special_chars($name) . '" value="'
|
||||||
. smarty_function_escape_special_chars($value) . '"';
|
. smarty_function_escape_special_chars($value) . '"';
|
||||||
|
|
||||||
if ($labels) $_output .= ' id="' . $_id . '"';
|
if ($labels && $label_ids) $_output .= ' id="' . $_id . '"';
|
||||||
|
|
||||||
if ((string)$value==$selected) {
|
if ((string)$value==$selected) {
|
||||||
$_output .= ' checked="checked"';
|
$_output .= ' checked="checked"';
|
||||||
|
Reference in New Issue
Block a user