how to add new option and the value is none on smarty?
<select>
{foreach from=$miles item=row1}
{html_options values=$row1.milestone_id outpu开发者_如何学Ct=$row1.title}
{/foreach}
</select>
I'll do you one better. If you set up your data array differently, you don't need the foreach:
<select>
<option value='null'>none</option>
{html_options values=$miles.milestone_id output=$miles.title}
</select>
{html_options}
creates a group of <option>
tags (see docs). Pass 2 arrays of value and output or just one associative array of name value pairs and it makes the whole lot of option tags. It'll also preselect the default value if you specify it.
It's just plain HTML, you don't need any Smarty formatting:
<select>
<option value='null'>none</option>
{foreach from=$miles item=row1}
{html_options values=$row1.milestone_id output=$row1.title}
{/foreach}
</select>
i think i just found.
<select name="1">
<option value='0'>-- none --</option>
{foreach from=$miles item=row1}
{html_options values=$row1.milestone_id output=$row1.title}
{/foreach}
</select>
精彩评论