I am trying to display an dropdown list with smarty html_options. It shows the dropdown nicely but output values as 0,1,2,3,4,5.
But I want values to be 100,150,200,250,300,350.
======PHP =========
$choice_set=array("A","B","C","D","E","F");
$choice_values=array(100,150,200,250,300,350);
$choice=250;
=====SMARTY=========
<select name="location">
{html_options values=$choice_values options=$choice_set selected=$choice}
</select>
Please help me to sort this out.
From their docs, it looks like you forgot to stick on the size bit for the select. Also, it says the
optionsneeds to beoutput(which seems like a really poor name to me). Like this:Update: Based on Gerald’s excellent point in the comments.
You could use the
optionstemplate value if you instead defined an associative array instead of separate arrays. So this would also work:======PHP =========
=====SMARTY=========
Also, I frequently forgot to
$smarty->assignmy variables, especially when I was prototyping or changing something. You’re probably smarter than me, in that regard, but it’s worth double checking.Sorry for my oversight, it’s been a while since I used smarty.