I have a set of arrays of php variables that are assigned into SMARTY template. The following is the php variable:
$smarty = new Smarty;
for ($i = 1; $i <= 3; ++$i) {
${'field'.$i} = array('group_rank_edit_' . $i, 'some_data'.$i);
// Assign variable to the template
$smarty->assign('field'.$i , ${'field'.$i});
}
So there are 3 arrays that are assigned to the template. Now, in the template I have difficulties on retrieving the values. Suppose the template is kinda like this:
{{for $i=1 to 3}}
$().ready(function() {
$("#group-ranks-edit-form").validate({
rules: {
{{$field.{{$i}}.0}}: {
required: true,
}
},
});
});
{{/for}}
So that one of the output will look like this:
$().ready(function() {
$("#group-ranks-edit-form").validate({
rules: {
group_rank_edit_1 : {
required: true,
}
},
});
});
Clearly the following format doesn't result the intended output:
{{$field.{{$i}}.0}}
Any ideas? I'm using Smarty 3 BTW.
Much appreciated