0
如何從表單對象(@ banner.name)讀取記錄參數?Rails3:form_for/simple_form_for記錄值
= simple_form_for @banner |f|
= f.name
...
= f.simple_fields_for :params do |o|
= o.name ????
= o.created_at ????
如何從表單對象(@ banner.name)讀取記錄參數?Rails3:form_for/simple_form_for記錄值
= simple_form_for @banner |f|
= f.name
...
= f.simple_fields_for :params do |o|
= o.name ????
= o.created_at ????
嘗試這種方式
= simple_form_for @banner |f|
= f.input :name
...
= f.simple_fields_for :params do |o|
= o.input :name
= o.input :created_at, :as => :date
但我不知道爲什麼你需要created_at的輸入。無論如何,與實施例中的文檔是在their Github page
爲了只顯示值有一個object
方法
= simple_form_for @banner |f|
= f.object.name
...
= f.simple_fields_for :params do |o|
= o.object.name
= o.object.created_at.strftime('%x %X') # strftime just to format
我想「回聲」的值不輸入對象。所以如何從f中獲得@ banner.name作爲字符串。 – xpepermint 2012-02-08 15:13:34
好的,編輯答案 – alony 2012-02-08 15:20:35
哈哈......那很簡單:)。 – xpepermint 2012-02-08 15:26:04