<% label = f.label :email %>
<% element = f.text_field :email %>
<% help = 'Please enter a valid email address' %>
<%= form_element label, element, help %>
Here we are in side a form_for block. This is the standard form_for block rails scaffolding builds for us. I am setting both the label and the form element and passing it to values. I suspect there is a better way to do this with blocks. If there is please reply to my post and let me know.
Next lets look at the form_element method.
def form_element(label, field, help)
return render :partial => 'shared/form_element', :locals => { :label => label, :field => field, :help => help }
end
Basically renders a partial and passes all the values to it. Here is the partial
<%= label %>
<%= field %>
<%= help %>
Done.