0
Rails的默認從名稱參數生成select_tag
編號和名稱:如何刪除ID和名稱從軌道屬性視圖助手
select_tag "people", "<option>David</option>".html_safe
# => <select id="people" name="people"><option>David</option></select>
但是,如果我們想生成select
沒有和id
和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>