Ben bir smarty dizideki değerlere dayalı kutularını kontrol etmek için çalışıyorum.
Benim php
$smarty->assign('locations_array',array(4,6,9,7));
I want to search through the array and if there is a match check the checkbox. Here is what I have tried in my template but I can't get it to work.I'm not sure how I can pass array_search the needle and haystack that it requires?
{foreach $locations as $x}
{if $x.id == $x.id|@array_search:$locations_array}
<label><input checked type="checkbox" name="locations[]" value="{$x.id}"/>{$x.title}</label>
{else}
<label><input type="checkbox" name="locations[]" value="{$x.id}" />{$x.title</label>
{/if}
{/foreach}
Bu özel bir işlevi yaratmadan mümkün mü?