开发者

question in html_checkboxes loop index in smarty template

开发者 https://www.devze.com 2023-01-19 11:00 出处:网络
i want know how to get the index of html_checkboxes loop ind开发者_JS百科ex with smarty for each checkbox ??

i want know how to get the index of html_checkboxes loop ind开发者_JS百科ex with smarty for each checkbox ??

http://www.smarty.net/manual/en/language.function.html.checkboxes.php


You would have to modify the function to do that. As written it's not designed to give you that information. If you need the index you can implement your check-boxes in a smarty loop:

<?php

$smarty->assign('checkboxes', array( 'value1', 'value2','value3','value4' ) );

?>

And your smarty code:

{ foreach from=$checkboxes item=value name=checkboxloop }
<input type="checkbox" name="whatever_name[{$smarty.foreach.checkboxloop.index}]" value="{$value}" />
{ /foreach }

So in that case the index (starting from zero) is access by {$smarty.foreach.checkboxloop.index} if you want it starting from 1 it's {$smarty.foreach.checkboxloop.iteration}

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号