Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 改革-访问嵌套表单范围内的父表单参数_Ruby On Rails_Ruby_Forms_Parameters_Reform - Fatal编程技术网

Ruby on rails 改革-访问嵌套表单范围内的父表单参数

Ruby on rails 改革-访问嵌套表单范围内的父表单参数,ruby-on-rails,ruby,forms,parameters,reform,Ruby On Rails,Ruby,Forms,Parameters,Reform,我使用的是1.2.6,有一个带验证的嵌套表单 简化: 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_

我使用的是1.2.6,有一个带验证的嵌套表单

简化:

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
class UserForm

参数是正确嵌套的,我只需要一种从嵌套表单访问父表单输入的方法。问题是嵌套表单似乎只能访问其参数集,而不能访问整个参数。

因此,基本上,这里真正需要的是使用Dispossible::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
要求“一次性/双胞胎/父母”
类UserForm
此外,您还可以阅读此主题: