Say I have two form_tag ‘s on a page, each like this:
= form_tag({:action => :import}, :multipart => true) do
= file_field_tag 'file'
= submit_tag 'Import', name: 'import_this'
So I know how that comes through in params but If I had two forms and each form had same name fields, how can I sort of namespace them in the resulting params array and how would I access them?
In order to differentiate between the two forms, you would need to create different names for the fields.
The most common practice is to nest the fields into a ‘namespace’, like this:
And the second form:
Then in the controller, you would access them like this:
or
Remember that you can’t submit both forms at the same time.