Reputation: 12957
I can't get what's the issue in below smarty code?
<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>
The assigned $staff_details array is as follows:
Array
(
[staff_id] => ff8d4a5ea6bf11dce105aa2fa7b959b8
[staff_type_id] => 2
[staff_full_name] => Chetan G
[staff_email] => [email protected]
[staff_password] => 123456
[staff_status] => enable
)
It's giving me the error:
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
Upvotes: 0
Views: 150
Reputation: 722
instead of
{foreach from=$staff_details item=$staff_info}
do
{foreach from=$staff_details item=staff_info}
Upvotes: 2