这是我的主要改革表格对象;
class CardHolderSupplierForm < ApplicationForm
property :supplier_id, validates: { presence: true }
property :standing_order, form: StandingOrderForm
end
而StandingOrderForm是;
class StandingOrderForm < ApplicationForm
property :amount_pence
property :reference
property :frequency
end
我在stand_orders中有一个名为amount_currency
的专栏应该始终是&#34; GBP&#34;。我似乎无法让改革把它推到我身边。我尝试了各种方法;
class StandingOrderForm < ApplicationForm
property :amount_pence
property :reference
property :frequency
# does nothing
def amount_currency
"GBP"
end
# does nothing - can't even binding.pry
def save
model.amount_currency = "GBP"
super
end
我不知道如何让这个工作。表单的其余部分正常工作。
答案 0 :(得分:0)
如何使用Reform的默认值设置?
property :amount_currency, default: "GBP"