Hello.. I have a form: <%= form_for @instruction_user, :url => some_path do |f|%> <% @users.each do |user| %> <%= user.name %> <%= f.input :prio, collection: 1..5, :as => :radio_buttons%> <%= f.text_field :remark%> <%= check_box_tag "instruction_user_ids[]", "#{user.id}" %> controller: if params[:instruction_user_ids] params[:instruction_user_ids].each do|user_id| InstructionUser.create( :user_id => user_id, :instruction_id => params[:instruction_id], :remark => ????, :prio => ??? ) end 1. The table rows are generated, but the attributes :prio_tl and :remark_tl are not in. How to write the [] .. take the form_fields? 2. Both attibutes need some indentifier!? I can not mark the radio-buttons per row seperately..as they have the same id.. Would be great to get some idea about the best way to handle the form and controller. Thanks a lot -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/ieqWfqlz2MoJ. For more options, visit https://groups.google.com/groups/opt_out.
Hi Werner, my dirty solution :) <%= f.input :prio, :as => :hidden %> <%= radio_button_tag :prio_tmp, 1, :onclick => "updatePrioHiddenValue(this.value)" %> <%= radio_button_tag :prio_tmp, 2, :onclick => "updatePrioHiddenValue(this.value)" %> .. .. using javascript function to update the :prio hidden value on radio button click. On Mon, Sep 24, 2012 at 8:11 PM, Werner <webagentur.laude-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>wrote:> Hello.. > > I have a form: > > <%= form_for @instruction_user, :url => some_path do |f|%> > > <% @users.each do |user| %> > <%= user.name %> > > <%= f.input :prio, collection: 1..5, :as => :radio_buttons%> > <%= f.text_field :remark%> > <%= check_box_tag "instruction_user_ids[]", "#{user.id}" %> > > controller: > if params[:instruction_user_ids] > params[:instruction_user_ids].each do|user_id| > InstructionUser.create( > :user_id => user_id, :instruction_id => > params[:instruction_id], :remark => ????, :prio => ??? > ) > end > > 1. The table rows are generated, but the attributes :prio_tl and > :remark_tl are not in. How to write the [] .. take the form_fields? > 2. Both attibutes need some indentifier!? I can not mark the radio-buttons > per row seperately..as they have the same id.. > Would be great to get some idea about the best way to handle the form and > controller. > > Thanks a lot > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/ieqWfqlz2MoJ. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- *David Angga Prasetya* *RoR Developers* skype: david.angga phone: +62 85 222 1 5555 2 * * -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Am 25.09.2012 um 03:59 schrieb David Angga <carsmetic.oc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: Thanks David.. may be I have to describe it better ... the form: <%= form_for @instruction_user, :url => some_path do |f|%> <% @users.each do | user | %> <%= f.input :prio, collection: 1..5, :as => :radio_buttons%> <%= f.text_field :remark%> <%= check_box_tag "instruction_user_ids[]", "#{user.id}" %> controller: params[:instruction_user_ids].each do| user_id | InstructionUser.create(...:remark => ????, :prio => ??? 1. The f.text_field :remark returns nothing because its getting overwritten by empty remark fields ..needs some [] . How is the best way? Tried "text_field_tag[]" and fields_for instruction[] with no success. I don''t know how to access the val in the controller. 2. Same with the radio buttons prio + the problem to mark the each line separately.. Would be great to get some idea.. Thanks> Hi Werner, > > my dirty solution :) > > <%= f.input :prio, :as => :hidden %> > <%= radio_button_tag :prio_tmp, 1, :onclick => "updatePrioHiddenValue(this.value)" %> > <%= radio_button_tag :prio_tmp, 2, :onclick => "updatePrioHiddenValue(this.value)" %> > .. > .. > > using javascript function to update the :prio hidden value on radio button click. > > On Mon, Sep 24, 2012 at 8:11 PM, Werner <webagentur.laude-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > Hello.. > > I have a form: > > <%= form_for @instruction_user, :url => some_path do |f|%> > > <% @users.each do |user| %> > <%= user.name %> > > <%= f.input :prio, collection: 1..5, :as => :radio_buttons%> > <%= f.text_field :remark%> > <%= check_box_tag "instruction_user_ids[]", "#{user.id}" %> > > controller: > if params[:instruction_user_ids] > params[:instruction_user_ids].each do|user_id| > InstructionUser.create( > :user_id => user_id, :instruction_id => params[:instruction_id], :remark => ????, :prio => ??? > ) > end > > 1. The table rows are generated, but the attributes :prio_tl and :remark_tl are not in. How to write the [] .. take the form_fields? > 2. Both attibutes need some indentifier!? I can not mark the radio-buttons per row seperately..as they have the same id.. > Would be great to get some idea about the best way to handle the form and controller. > > Thanks a lot > > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/ieqWfqlz2MoJ. > For more options, visit https://groups.google.com/groups/opt_out. > > > > > > -- > David Angga Prasetya > RoR Developers > > skype: david.angga > phone: +62 85 222 1 5555 2 > > > > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > >Werner Laude webagentur.laude-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
You can try using simple_form_for instead of form_for. Check this link :- https://github.com/plataformatec/simple_form On Monday, September 24, 2012 6:41:15 PM UTC+5:30, Werner wrote:> > Hello.. > > I have a form: > > <%= form_for @instruction_user, :url => some_path do |f|%> > > <% @users.each do |user| %> > <%= user.name %> > > <%= f.input :prio, collection: 1..5, :as => :radio_buttons%> > <%= f.text_field :remark%> > <%= check_box_tag "instruction_user_ids[]", "#{user.id}" %> > > controller: > if params[:instruction_user_ids] > params[:instruction_user_ids].each do|user_id| > InstructionUser.create( > :user_id => user_id, :instruction_id => > params[:instruction_id], :remark => ????, :prio => ??? > ) > end > > 1. The table rows are generated, but the attributes :prio_tl and > :remark_tl are not in. How to write the [] .. take the form_fields? > 2. Both attibutes need some indentifier!? I can not mark the radio-buttons > per row seperately..as they have the same id.. > Would be great to get some idea about the best way to handle the form and > controller. > > Thanks a lot > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/SmaL6Oh6LMIJ. For more options, visit https://groups.google.com/groups/opt_out.
Am 25.09.2012 um 13:34 schrieb Avi <aavinash.behera-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> You can try using simple_form_for instead of form_for. > Check this link :- https://github.com/plataformatec/simple_form > > <%= form_for @instruction_user, :url => some_path do |f|%> > > <% @users.each do |user| %> > <%= user.name %>I have tried: <%= form_tag new_fb_instruction_users_path, :method => :post do %> .... <%= simple_fields_for "instruction[]", @instruction_user do |f| %> <%=f. input "remark%> controller: ..:remark => params[:instruction][:remark] log: "instruction"=>[{"remark"=>"test"} => can''t convert Symbol into Integer phh...> > <%= f.input :prio, collection: 1..5, :as => :radio_buttons%>> <%= f.text_field :remark%> > <%= check_box_tag "instruction_user_ids[]", "#{user.id}" %> > > controller: > if params[:instruction_user_ids] > params[:instruction_user_ids].each do|user_id| > InstructionUser.create( > :user_id => user_id, :instruction_id => params[:instruction_id], :remark => ????, :prio => ??? > ) > end > > 1. The table rows are generated, but the attributes :prio_tl and :remark_tl are not in. How to write the [] .. take the form_fields? > 2. Both attibutes need some indentifier!? I can not mark the radio-buttons per row seperately..as they have the same id.. > Would be great to get some idea about the best way to handle the form and controller. > > Thanks a lot > > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/SmaL6Oh6LMIJ. > For more options, visit https://groups.google.com/groups/opt_out. > >Werner Laude webagentur.laude-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.