I want to use form template to render data for show. My idea is, to readonly/disable formelements. This works fine, except with selects. The following three variants of render code do not emit the keyword disabled to the html text: f.select :attr, @choices, :include_blank => true, :disabled => !@condition f.select :attr, @choices, {:include_blank => true}, :disabled => !@condition f.select :attr, @choices, {:include_blank => true}, {:disabled => !@condition} Writing readonly instead if disabled (which seems to be undefined for select) also doesn''t have any effects. What is going wrong? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Fritz Trapper wrote:> I want to use form template to render data for show.Generally not a good idea from a UI point of view. Just use plain text for display, unless you want to allow editing.> > My idea is, to readonly/disable formelements. This works fine, except > with selects. The following three variants of render code do not emit > the keyword disabled to the html text: > > f.select :attr, @choices, :include_blank => true, > :disabled => !@condition > f.select :attr, @choices, {:include_blank => true}, > :disabled => !@condition > f.select :attr, @choices, {:include_blank => true}, > {:disabled => !@condition} > > Writing readonly instead if disabled (which seems to be undefined for > select) also doesn''t have any effects. > > What is going wrong?Are you sure !@condition is true when you expect it to be? Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser wrote:> Are you sure !@condition is true when you expect it to be?Yes, I checked it in the debugger. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Try f.select :attr, @choices, {:include_blank => true}, { :disabled => !@condition } On Mon, Sep 13, 2010 at 11:44 PM, Fritz Trapper <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> Marnen Laibow-Koser wrote: > > Are you sure !@condition is true when you expect it to be? > > Yes, I checked it in the debugger. > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> f.select :attr, @choices, :include_blank => true, > :disabled => !@condition > f.select :attr, @choices, {:include_blank => true}, > :disabled => !@condition > f.select :attr, @choices, {:include_blank => true}, > {:disabled => !@condition}I remember struggling with this a while back too. This worked for me: <%= f.select :attr, @choices, {}, :include_blank => true, :disabled => !@condition %> I believe the problem lies with the empty hash for the options. This is the signature from the documentation: select(object, method, choices, options = {}, html_options = {})> > Writing readonly instead if disabled (which seems to be undefined for > select) also doesn''t have any effects. > > What is going wrong? > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
> <%= f.select :attr, > @choices, > {}, > :include_blank => true, > :disabled => !@condition %>It just happens that I''m working on the very same thing again and the problem with the above is that when the select is not disabled it actually does not include the empty option. Running Rails 2.3.5 & Ruby 1.8.6 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.