我無法在我的視圖中顯示下拉列表。 這是我的編輯動作表單。我有這個錯誤:wrong number of arguments (1 for 2)
。Haml form_for下拉列表
0
A
回答
1
試試這個:
= form_for @question do |w| %p %select{ :name => "question[question_status]" } %option{:value => 1}= "label 1" %option{:value => 2}= "label 2" %p = w.submit "Update" %p = link_to 'Back', :back
0
你可以這樣說:
w.select :question_status, @question.map {|q| [q.label,q.value] }
,或者如果你想讓它靜態
w.select :question_status, [['label1',value],['label2',value]]
1
我認爲這應該爲你工作,讓我知道這些關切。
= form_for @question do |w|
%p
= w.select "question_status", [["1", "label 1"], ["2", "label_2"]]
%p
= w.submit "Update"
%p
= link_to 'Back', :back
相關問題
- 1. haml。下拉里阿斯中的form_for
- 2. HAML/HTML下拉列表爲表列
- 3. 在HAML中選擇列表(下拉列表)
- 4. 下拉菜單中的表與Haml
- 5. 下拉列表中的下拉列表
- 6. 如何在下拉列表
- 7. 下拉列表
- 8. 下拉列表
- 9. 下拉列表
- 10. 下拉列表
- 11. 下拉列表
- 12. HAML rails form_for不調用POST方法
- 13. HAML form_tag下拉菜單問題
- 14. django下拉列表
- 15. 下拉列表第
- 16. 3.3.3下拉列表
- 17. 下拉列表(PHP)
- 18. jQuery下拉列表
- 19. 與下拉列表
- 20. Telerik下拉列表
- 21. MVC3下拉列表
- 22. HTML下拉列表
- 23. MVC下拉列表
- 24. iPhone下拉列表
- 25. jquery下拉列表
- 26. 宏下拉列表
- 27. asp.net下拉列表
- 28. 在下拉列表
- 29. onchange下拉列表
- 30. MVC下拉列表
edit.html.haml:3:語法錯誤,意想不到tASSOC,期待 '}' –
變化到這個' = w.select 「question_status」 %選項{:值=> 1} =「標籤1「 %option {:value => 2} =」label 2「 錯誤的參數數量(1代表2) –
測試我自己的實例並更正了'select'行。現在應該工作。 –