Rename form

6 views
Skip to first unread message

nav...@10eighteen.com

unread,
Mar 5, 2014, 6:13:39 PM3/5/14
to plataformate...@googlegroups.com
Hi

Is it possible to rename the form so that the input fields are submitted under a different key in the params hash. Here's what I mean:

<%= simple_form_for @foo, url: some_path, do |f|  %>
  <%= f.input :waffle %>
...
<% end %>

would generate a hash

{ foo: { waffle: 'yes' } }

I would like to obtain a hash like so:

{ bar: { waffle: 'yes' } }

I can change the name on each input (example below) but was wondering if there is a better way to change the form name instead

<%= f.input :waffle, input_html: { name: 'bar[waffle]' } %>


Thanks heaps
Message has been deleted

Vasiliy Ermolovich

unread,
Mar 6, 2014, 2:40:08 AM3/6/14
to plataformate...@googlegroups.com
Hey, you can pass :as option to the simple_form method:

<%= simple_form_for @foo, as: :bar, url: some_path, do |f| %>

nav...@10eighteen.com wrote:
--
You received this message because you are subscribed to the Google
Groups "SimpleForm" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to plataformatec-simp...@googlegroups.com
<mailto:plataformatec-simp...@googlegroups.com>.
For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages