Search code examples
ruby-on-railsruby-on-rails-4simple-form

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


I'm using simple form and I have a long form divided in partials, each partial represents a category.

enter image description here

For example, identification_form is:

enter image description here

I'd like the inputs to get a name like this:

enter image description here

Is possible to do this?

I can change the names by myself, but the problem is simple_form is not able to create the names for the stat_date and end_date (act[start_date(1i), act[start_date(2i), act[start_date(3i), it adds the same name for the three inputs.

Thanks!


Solution

  • Yes it is!

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

    The above will give you:

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

    This should then work with dates.

    Edit:

    I think you should be using date_select rather than input.