Hello,

I also have the same problem setting business categories as primary in 
my edit_categories page using a radio_button.  The radio_button's 
behavior changes, all buttons can be selected and can't be de-selected. 
Everything works fine on my "new" page.  My codes is also like what Raji 
had.  I added an onclick action just so user can de-select the 
radio_button(it's now like a checkbox) and a note that user can just set 
one category as primary.

Does anyone know a better way to solve this problem in a much cleaner 
way? Please help.

I had this helper method which checks if the data already exist:

  def fields_for_business_category(category, &block)
    prefix = category.new_record? ? '' : 'existing_'
    fields_for("#{prefix}category_attributes[]", category, &block)
  end

This is my view:

<% category = business_category %>
<% fields_for_business_category(category) do |category_form| %>
<%= category_select_tag("category_id", category_form, {:class => 
'search'})%>
<%= category_form.radio_button("primary_category", "Y", 
:onmousedown=>"this.chk = this.checked", :onclick=>"if (this.chk) 
this.checked = false")%>
<%end%>

Thanks in advance..^_^
-- 
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to