Hi I want to disable only one item of select box. I tried to used :disabled=>''item'' but it disable select box itself. So anybody how to do this? Thanks Brijesh Shah -- Posted via http://www.ruby-forum.com/.
Brijesh Shah wrote:> Hi > > I want to disable only one item of select box. > > I tried to used :disabled=>''item'' but it disable select box itself. > > So anybody how to do this? > > Thanks > Brijesh ShahHi Brijesh, I hope the following example would help you.. If not put your code here.. Example: select("post", "category", Post::CATEGORIES, {:disabled => ''restricted''}) could become: <select name="post[category]"> <option></option> <option>joke</option> <option>poem</option> <option disabled="disabled">restricted</option> </select> -- Posted via http://www.ruby-forum.com/.
> I hope the following example would help you.. If not put your code > here.. > > Example: > > select("post", "category", Post::CATEGORIES, {:disabled => > ''restricted''}) > > could become: > > <select name="post[category]"> > <option></option> > <option>joke</option> > <option>poem</option> > <option disabled="disabled">restricted</option> > </select>Thanks for your reply.. But this code does not work..there is no effect on select box. if I tried this, select("post", "category", Post::CATEGORIES,{}, {:disabled => ''restricted''}) then select box is disabled rather than one item.. -- Posted via http://www.ruby-forum.com/.
read rails doc,there is one noticed thing. {:disabled =>''restricted''} is valid hint ''restrcted''must be select value,can imply disabled function. eg: <%= select("message", "id", Message.all.collect {|p| [ p.title, p.id ] }, { :disabled => 16 }) %> and view render code: test select disabled values <select id="message_id" name="message[id]"><option value="14">第一</option> <option value="15">第二</option> <option value="16" disabled="disabled">第三</option></select> 2009/11/2 Brijesh Shah <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>> > > I hope the following example would help you.. If not put your code > > here.. > > > > Example: > > > > select("post", "category", Post::CATEGORIES, {:disabled => > > ''restricted''}) > > > > could become: > > > > <select name="post[category]"> > > <option></option> > > <option>joke</option> > > <option>poem</option> > > <option disabled="disabled">restricted</option> > > </select> >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 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 -~----------~----~----~----~------~----~------~--~---
tommy xiao wrote:> read rails doc,there is one noticed thing. > > {:disabled =>''restricted''} is valid hint > ''restrcted''must be select value,can imply disabled function. > > eg: > <%= select("message", "id", Message.all.collect {|p| [ p.title, p.id > ] > }, { :disabled => 16 }) > %> > > and view render code: > > test select disabled values > > <select id="message_id" name="message[id]"><option > value="14">第一</option> > <option value="15">第二</option> > <option value="16" disabled="disabled">第三</option></select> > > > > 2009/11/2 Brijesh Shah <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Thanks for help... Actually I tried with :disabled =>"16" instead of 16 and thats why I did not get result... Now it works fine... -- Posted via http://www.ruby-forum.com/.
Brijesh Shah wrote:> Hi > > I want to disable only one item of select box. > > I tried to used :disabled=>''item'' but it disable select box itself. > > So anybody how to do this? > > Thanks > Brijesh ShahHi Brijesh, As per your need, i think you want to disable particular item from select box. so here is the solution, <%= select(:record, :property_id, Property.all.collect {|p| [ p.name, p.id ] }, :disabled => 2 [it''s the id which you want to disable] ) %> Hope this will help you. Thanks, Priyanka Pathak -- Posted via http://www.ruby-forum.com/.