I add the following to 'app/helpers/global_helper.rb'.

    def radio_button(*args)
      opts = args.last
      opts[:checked] = "checked" if opts.is_a?(Hash) && opts.delete
(:checked)
      super
    end

ex.
    <%= radio_button :name=>"foo", :value=>"Y", :checked=>params[:foo]
=="Y" %>
     #=> <input type="radio" name="foo" value="Y" checked="checked" />
     #=>  or <input type="radio" name="foo" value="Y" />

--
regards,
makoto kuwata


On Dec 3, 11:35 am, "Makoto Kuwata" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a question about :checked option of radio_button helper.
> I expected that radio_button helper generates 'checked="checked"'
> or '' when :checked is true or false, but it generates
> 'checked="true"' or 'checked="false"' in actual.
>
> ex.
>     <%= radio_button :name=>'test1', :value=>'t1', :checked=>false %>
>     #=> <input type="radio" value="t1" class="radio" name="test1"
> checked="false"/>
>     # (expected) <input type="radio" value="t2" class="radio" name="test1"/>
>
> Is this intended spec?
>
> The following example is described in document of radio_button,
> so my expectation seems not to be wrong.
>
>   <%= radio_button :name => "radio_options", :value => "3", :label =>
> "Three", :checked => true %>
>
> (version: merb-heleprs 1.0.2)
>
> --
> regards,
> makoto kuwata
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to