我需要动态填充一些文本框,一个数组包含标签,第二个数组包含我想用来填充的值
Array ( [Enquiry] => Enquiry [Application Sent] => Application Sent [Application Received] => Application Received [Interview Booked] => Interview Booked [Offer Made] => Offer Made [Offer Accepted] => Offer Accepted [Deposit Paid] => Deposit Paid ) 1
Array ( [0] => 10 [1] => [2] => [3] => [4] => [5] => 5 [6] => ) 1
文本框是基于第一个数组创建的,我需要检查第一个数组中的位置,并用第二个数组中相应索引的值填充文本框中的值。因此查询的值为 10,接受的报价为 5,依此类推。
如何在以下 smarty 代码中执行此操作?我以前从未真正与 smarty 合作过。
<input type="hidden" id="{{if empty($displayParams.idName)}}{{sugarvar key='name'}}{{else}}{{$displayParams.idName}}{{/if}}_multiselect"
name="{{if empty($displayParams.idName)}}{{sugarvar key='name'}}{{else}}{{$displayParams.idName}}{{/if}}_multiselect" value="true">
{multienum_to_array string={{sugarvar key='options' string=true}} default={{sugarvar key='default' string=true}} assign="values"}
{$values|@print_r}
{multienum_to_array string={{sugarvar key='value' string=true}} default={{sugarvar key='default' string=true}} assign="vals"}
{$vals|@print_r}
{foreach from=$values key=k item=item}
{if @in_array($k, $vals)}
{assign var=v value=true}
{else}
{assign var=v value=false}
{/if}
<input size="2" type="text" id="" name="{{if empty($displayParams.idName)}}{{sugarvar key='name'}}{{else}}{{$displayParams.idName}}{{/if}}[]" value="{ {{sugarvar key='value' string=true}}.$item }" />% <label>{ {{sugarvar key='options' string=true}}.$item }</label><br />
{/foreach}