I'm using Reform 1.2.6 and have a nested form with validation
我正在使用Reform 1.2.6并且有一个带有验证的嵌套表单
Simplified:
简化:
class UserForm < Reform::Form
property :date_of_birth
property health_profile do
property :diagnosed_with_condition_at
validate :diagnosed_date
def diagnosed_date
# need to get access to date_of_birth here
# validate that diagnosed_with_condition_at is after date of birth
end
end
end
Params come in properly nested, I just need a way to get access to parent form inputs from the nested form. The problem is that nested form seems to only have access to its set of params, and not the whole params.
Params正确嵌套,我只需要一种从嵌套表单访问父表单输入的方法。问题是嵌套表单似乎只能访问它的一组参数,而不是整个参数。
1 个解决方案
#1
1
So, basically what you really need here is to use Disposable::Twin::Parent feature.
所以,基本上你真正需要的是使用Disposable :: Twin :: Parent功能。
require 'disposable/twin/parent'
class UserForm < Reform::Form
feature Disposable::Twin::Parent
property :date_of_birth
property health_profile do
property :diagnosed_with_condition_at
validate :diagnosed_date
def diagnosed_date
self.parent.date_of_birth
end
end
end
Also, you can read this topic: https://github.com/apotonick/disposable/issues/61
此外,您可以阅读此主题:https://github.com/apotonick/disposable/issues/61
#1
1
So, basically what you really need here is to use Disposable::Twin::Parent feature.
所以,基本上你真正需要的是使用Disposable :: Twin :: Parent功能。
require 'disposable/twin/parent'
class UserForm < Reform::Form
feature Disposable::Twin::Parent
property :date_of_birth
property health_profile do
property :diagnosed_with_condition_at
validate :diagnosed_date
def diagnosed_date
self.parent.date_of_birth
end
end
end
Also, you can read this topic: https://github.com/apotonick/disposable/issues/61
此外,您可以阅读此主题:https://github.com/apotonick/disposable/issues/61