开发者

smarty select option

开发者 https://www.devze.com 2022-12-15 21:19 出处:网络
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}

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消