0

我无法在下面的 smarty 代码中得到什么问题?

<select class="list_items" name="staff_id" id="staff_id">
                  <option value="">All</option>
                    {if $staff_details}
                      {foreach from=$staff_details item=$staff_info}
                  <option value="{$staff_info.staff_id}"  {if $staff_id==$staff_info.staff_id} selected="selected"{/if}>{$staff_info.staff_full_name}</option>
                      {/foreach}
                    {/if}  
                  </select>

分配的 $s​​taff_details 数组如下:

Array
(
    [staff_id] => ff8d4a5ea6bf11dce105aa2fa7b959b8
    [staff_type_id] => 2
    [staff_full_name] => Chetan G
    [staff_email] => admin@gmail.com
    [staff_password] => 123456
    [staff_status] => enable
)

它给了我错误:

Fatal error: Smarty error: [in chapter-mcq-questions.tpl line 45]: syntax error: 'foreach: 'item' must be a variable name (literal string) (SmartyCompiler.php, line 1183) in /var/www/schooling_needs/core/libs/Smarty.php on line 1095 
4

1 回答 1

2

代替

{foreach from=$staff_details item=$staff_info}

{foreach from=$staff_details item=staff_info}
于 2013-06-12T07:57:37.970 回答