select_tag
Rails默认为 name 参数生成 id 和 name :
select_tag "people", "<option>David</option>".html_safe
# => <select id="people" name="people"><option>David</option></select>
但是,如果我们想生成select
没有 andid
和name
属性怎么办?
像这样:
<select><option>David</option></select>
空名称参数不起作用,空 html 属性仍然存在:
select_tag "", "<option>David</option>".html_safe
# => <select id name><option>David</option></select>
手动id
和name
分配不起作用
select_tag "people", "<option>David</option>".html_safe, id: false, name: false
# => <select id=false name=false><option>David</option></select>
select_tag "people", "<option>David</option>".html_safe, id: '', name: ''
# => <select id name><option>David</option></select>