Re: radio_button_tag

Hi

Radio buttons need to belong to the same group to be able to work
together. In your code you have two different groups, or attributes,
:actuel and :last. These need to be the same - the general form of the
radio_button_tag helper is:
radio_button_tag(:attribute, tag_value, options). You can then determine
which one was pressed when the form is submitted by the value of the
button given in the params hash

HTH

Clive

unknown wrote:

Hi

Radio buttons need to belong to the same group to be able to work
together. In your code you have two different groups, or attributes,
:actuel and :last. These need to be the same - the general form of the
radio_button_tag helper is:
radio_button_tag(:attribute, tag_value, options). You can then determine
which one was pressed when the form is submitted by the value of the
button given in the params hash

HTH

Clive

Hello

Thanks for your answer.

I had put the radio buttons with the same name to be on the same group.

actuel <%= radio_button_tag(:type_recherche, value = "1", checked = false, options = {}) %> last <%= radio_button_tag(:type_recherche, value = "2", checked = false, options = {}) %>

To pass the values I use a link_to_remote:

<%= link_to_remote “Rechercher”,
:update => “resultlist”,
:url => { :action => ‘rechercher’},
:with => “…+ ‘&’ +
‘type_recherche=’ + $F(‘type_recherche’)”,
:complete => visual_effect(:appear, ‘resultlist’, :duration => 1.00)
%>

In my controller when i try to access to the “type_recherche” value (my
2 radio buttons), I do this:

if params[:type_recherche].nil?
puts “1”
@demand.type_recherche = “0”
else
if params[:type_recherche].to_s == ‘null’
@demand.type_recherche = “0”
else
puts "6 -> " + params[:type_recherche].to_s
@demand.type_recherche = params[:type_recherche]
end
end

When i check the first radio it works fine. I receive the value “1”. But
when i check the second radio button, i always receive null. It seems
that the only radio button used is the first one.

Any idea about this problem.

Thanks