How to get param values through radio_buttons ?
I'm trying to create a TARGET with a responsible user via form_with:
<div class="form-group-users">
<% @users.each do |user| %>
<div class="custom-control custom-radio">
<%= f.radio_button :responsible_id ,'', id:"responsible-manage-#{user.id}", class:'custom-control-input' %>
<label class="custom-control-label" for="responsible-manage-<%= user.id %>">
<div class="d-flex align-items-center">
<%= image_tag user_avatar(user.id), class:'avatar mr-2', 'data-title' => user.first_name , 'data-toggle':'tooltip' %>
<span class="h6 mb-0" data-filter-by="text"><%= user.first_name %> <%= user.last_name %></span>
</div>
</label>
</div>
<% end %>
</div>
The problem here is that params for responsible_id is empty.
Parameters: {"utf8"=>"✓", "authenticity_token"=>"+gh9H09zXkp+W0cUeZO12HDPgWHqWWcVsW+XxD/8o68srfQt/Od0MH/kYNYe6KxQZ2ncFDVq3v5RK267NEPEYw==", "target"=>{"title"=>"Target 2", "description"=>"", "due_date"=>"2018-12-31", "responsible_id"=>"", "team_id"=>""}, "visibility"=>"on", "commit"=>"Create"}
Any ideas?
Hey rodolfo,
You need to add the value you want passed for each radio button. If you check out the docs, you'll see the structure is: radio_button(method, tag_value, options = {})
So your tag should look like this:
<%= f.radio_button :responsible_id , client.id, id:"responsible-manage-#{user.id}", class:'custom-control-input' %>