Hello

I'm trying to search for active and non active users. These radio buttons
work just fine except that it didn't reselect itself after the form has
been submitted. So, what should I do to ensure it will be selected just
like how my text field populated automatically after the form has been
submitted?

= search_form_for @q do |f|
= f.radio_button :is_active_false, 1
= f.radio_button :is_active_true, 1

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/LKxcEyGf-2MJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Lucca Mordente at Aug 20, 2012 at 6:46 pm
    Hi Amree,

    Try something like this:

    = f.radio_button :is_active_false, 1, :checked => @search.is_active_false
    = f.radio_button :is_active_true , 1, :checked => @search.is_active_true

    Let me know if this works for you.

    Also, aren't you able to check both buttons at the same time, given that
    the have different name attribute from each other?


    Em domingo, 20 de novembro de 2011 07h42min39s UTC-2, Amree escreveu:

    Hello

    I'm trying to search for active and non active users. These radio buttons
    work just fine except that it didn't reselect itself after the form has
    been submitted. So, what should I do to ensure it will be selected just
    like how my text field populated automatically after the form has been
    submitted?

    = search_form_for @q do |f|
    = f.radio_button :is_active_false, 1
    = f.radio_button :is_active_true, 1

    Thanks in advance.
    --
    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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/V7Y2J75VOfwJ.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Lucca Mordente at Aug 20, 2012 at 6:50 pm
    Amree,

    have you tried the :checked option?

    That was the only solution for me.
    If anyone have any better solution, please post here.

    Lucca Mordente


    On Thu, Aug 16, 2012 at 1:15 PM, Lucca Mordente wrote:

    Hi Amree,

    Try something like this:

    = f.radio_button :is_active_false, 1, :checked => @search.is_active_false
    = f.radio_button :is_active_true , 1, :checked => @search.is_active_true

    Let me know if this works for you.

    Also, aren't you able to check both buttons at the same time, given that
    the have different name attribute from each other?


    Em domingo, 20 de novembro de 2011 07h42min39s UTC-2, Amree escreveu:

    Hello

    I'm trying to search for active and non active users. These radio buttons
    work just fine except that it didn't reselect itself after the form has
    been submitted. So, what should I do to ensure it will be selected just
    like how my text field populated automatically after the form has been
    submitted?

    = search_form_for @q do |f|
    = f.radio_button :is_active_false, 1
    = f.radio_button :is_active_true, 1

    Thanks in advance.
    --
    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@googlegroups.com.
    To unsubscribe from this group, send email to
    rubyonrails-talk+unsubscribe@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msg/rubyonrails-talk/-/V7Y2J75VOfwJ.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Michael Pope at Oct 18, 2012 at 12:53 am
    I use a drop down box as then I can select true, false or don't care
    (blank).

    = f.select :my_bool_field_eq, options_for_select([false, true]),
    include_blank: true

    --
    Posted via http://www.ruby-forum.com/.

    --
    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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedNov 20, '11 at 1:00p
activeOct 18, '12 at 12:53a
posts4
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2022 Grokbase