Smarty {html_radio}如何让它成为必需的?

Smarty {html_radio} how to make it required?

我正在寻找如何使用 smarty 自定义函数制作所需的单选按钮组 {html_radio} http://www.smarty.net/docs/en/language.function.html.radios.tpl

这是我的代码:

{html_radios name='radio' options=$radio_options separator='<br />'}

谢谢。

从 tools/smarty/ 挖掘到 function.html_radios.php 并看到了 $extra 变量。

if (!is_array($_val)) {
   $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
}

此外,在 http://www.smarty.net/docs/en/language.function.html.radios.tpl 中,请参阅 "strict" 属性。

因此,我的代码如下所示:

{html_radios required='required' name='radio' options=$radio_options separator='<br />'}

而且效果很好。