dtwvr26066 2014-10-29 00:22
浏览 42

html_checkboxes Smarty

I work with form using Smarty. There are some validation to check the phone number and email using regular expression. And if it's all correct, users can jump into the confirmation page, otherwise these checks shuold be remained. I use checkboxes_html with some option "selected". But all checks I made are gone if the validation doesn't succeed.

[php]

// Lists for the radio button
$smarty->assign('genre_output', array('apple','chiken','tuna'));
$smarty->assign('genre_values', array('apple','chiken','tuna'));

[html]

<tr>
<th>Genre</th>
<td>
{html_checkboxes name="genre" values=$genre_values output=$genre_output selected="{$data['genre']|escape}" separator='<br />'}
</td>
</tr>
  • 写回答

1条回答 默认 最新

  • doutan2456 2015-02-05 11:06
    关注

    Try the following code. It works for me:

    tpl file:

    <form action="" method="post">
       {html_checkboxes name="genre" values=$genre_values output=$genre_output selected=$genre_selected separator=""}
       <input type="submit">
    </form>
    

    php file:

    $smarty->assign('genre_output', array('apple','chiken','tuna'));
    $smarty->assign('genre_values', array('apple','chiken','tuna'));
    $smarty->assign('genre_selected', $_POST['genre']);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大