0
每當我做了以下也不會在表單上顯示的任何子字段:如何獲得formtastic的嵌套窗體?
= f.semantic_fields_for :transfers do |g|
如果我singularize,他們顯示但隨後該模型沒有什麼線索做:transfer
。我試圖爲accepts_nested_attributes_for
做單數匹配,但那也沒用。
交易:
has_many :transfers
accepts_nested_attributes_for :transfers
轉移:
belongs_to :transaction
觀點:
= semantic_form_for [@user, @transaction], url: url, style: "width: inherit;" do |f|
= f.semantic_fields_for :transfers do |g|
= g.inputs do
= g.input :amount
%li
%label
= "(#{Transfer::TRANSFER_FEE.format :symbol} transaction fee will be added)"
= g.inputs do
%li
%label
Click
%input{ type: "image", value: "submit", style: "vertical-align: middle;",
src: "https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" }
or fill in your credit card information below
= g.inputs do
= g.input :first_name
= g.input :last_name
= g.input :card_type, as: :select, collection: [["Visa", "visa"], ["MasterCard", "master"], ["Discover", "discover"], ["American Express", "american_express"]]
= g.input :card_number
= g.input :card_verification
= g.input :card_expires_month, as: :select, collection: (1..12)
- year = Time.now.year
= g.input :card_expires_year, as: :select, collection: (year..(year+25))
= f.inputs do
%li
%label
%input{ type: "submit", value: "Buy", name: "use_cc" }
輸入塊(第3行)是否需要在semantic_fields_for塊之外? – 2012-02-14 19:27:26
它不需要在那裏,但它也不會影響它。 – skeemer 2012-02-15 22:37:21
對不起,我奇怪地問了我的問題。只是爲了澄清,如果將semantic_fields_for塊封裝在輸入塊中,它沒有任何作用? – 2012-02-15 23:16:35