Wednesday, June 16, 2010

[Rails] Multiple classes on form text_field

Consider :

- - - -

<% form_for(@z) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :x %><br />
<%= f.text_field :x, :class => 's' %>
</p>
<p>
<%= f.submit 'Update' %>
</p>
<% end %>

- - - -

The above form works fine. What I want to do is have two classes, s and
t, associated with text_field :x.

The following does not work.

- - - -

<% form_for(@z) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :x %><br />
<%= f.text_field :x, :class => {'s', 't'} %>
</p>
<p>
<%= f.submit 'Update' %>
</p>
<% end %>

- - - -

The code above will generate a single class class="st"

How can I have two classes in the same field using form helper? Do I
have to generate my own html?
--
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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate