是否可以以除以部分的形式向输入添加名称空间?

Is possible to add a namespace to the inputs in a form divided by partials?

我使用的是简单表格,我有一个分为部分的长表格,每个部分代表一个类别。

例如identification_form是:

我希望输入的名称是这样的:

可以这样做吗?

我可以自己更改名称,但问题是 simple_form 无法为 stat_date 和 end_date 创建名称(act[start_date (1i),act[start_date(2i),act[start_date(3i),它为三个输入添加相同的名称。

谢谢!

是的!

f.fields_for :identification do |identification_form|
  identification_form.input :name

以上会给你:

<input type="text" name="act[identification][name]" />

这应该适用于日期。

编辑:

我认为你应该使用 date_select 而不是 input