Ruby on Rails
Thursday, July 30, 2015
<%= f.select_time Time.now, prefix: :start_time %>
On Thursday, July 30, 2015 at 11:35:28 AM UTC-4, Federicko wrote:
Hi,
I have a simple form using form_for but I need to have a field in the form that uses select_time which is not part of the FormHelper and there lies the issue.
<%= form_for [:admin, @restaurant, @opening_hour] do |f| %><div class="field">
<%= f.label :day %><br><%= f.text_field :day %></div><div class="field"><%= f.label :start_time %><br><%= select_time Time.now, prefix: :start_time %></div>
<% end %>
The form above works fine except that the params passed over to the controller is separate:
params[:opening_hour]
params[:start_time]
Now as a newbie, all I have been doing in the controller is to use one params, params[:opening_hour], for all the form data. But with this form that produces two params, I don't know how to combine them both into one so my controller will work. Especially cos the params maps to the model object.
Any ideas?
Thanks in advance.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9d9f9cd4-4af8-4807-b9d0-9d089babaab9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment