Hi
I have a doubt. Dont know it is valid. Just asking. I am trying to
reuse the same partial _form for both new and edit. So from new.html.erb
I call partial like
<%= render :partial => ''user_fields'', :locals => {:f
=> f}%>
and in _user_fields.html.erb an example field as
<p>
<%= u.label :first_name,''First Name'' %>
<%= u.text_field :first_name,:maxlength => 50 %>
</p>
My question is if I call this same partial in edit.html.erb also,
how can I apply the h() method like below (since this fields being
populated with value from db being an edit form)
<p>
<%=h u.label :first_name,''First Name'' %>
<%=h u.text_field :first_name,:maxlength => 50 %>
</p>
Thanks in advance
Tom
--
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.
> My question is if I call this same partial in edit.html.erb also, > how can I apply the h() method like below (since this fields being > populated with value from db being an edit form) > > <p> > <%=h u.label :first_name,''First Name'' %> > <%=h u.text_field :first_name,:maxlength => 50 %> > </p> >I''m pretty sure the text_field method will cover that for you - you wouldn''t want to put the h where you have there or you''d end up escaping the actual <input type="text" /> field. If you really wanted to override the value then you could do something like this: <%= u.text_field :first_name, :value => h(your_value) %> -- 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.
On 23 Mar, 07:46, Tom Mac <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi > I have a doubt. Dont know it is valid. Just asking. I am trying to > reuse the same partial _form for both new and edit. So from new.html.erb > I call partial like >Well it is valid but not useful - The label help would generate something like <label for=''first_name>First Name</label> But then h comes along and escapes the whole lot (not just the label contents) - try it for yourself! Fred> <%= render :partial => ''user_fields'', :locals => {:f => f}%> > > and in _user_fields.html.erb an example field as > > <p> > <%= u.label :first_name,''First Name'' %> > <%= u.text_field :first_name,:maxlength => 50 %> > </p> > > My question is if I call this same partial in edit.html.erb also, > how can I apply the h() method like below (since this fields being > populated with value from db being an edit form) > > <p> > <%=h u.label :first_name,''First Name'' %> > <%=h u.text_field :first_name,:maxlength => 50 %> > </p> > > Thanks in advance > Tom > -- > 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.