简体   繁体   中英

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>

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']);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM