Arbitrary elements in form_for?

I would like to use form_for in my project so that I can easily change
the style of many forms at once. However, it seems to me like
FormBuilders only support certain kinds of form elements(!). Surely
there must be a way to add arbitrary labels/form elements to a form.

Let’s say I had a form that looks like:

ID: (plain-text label)
Name: (text field)
Birthdate: (date chooser)
Picture: (picture)
Foo: (custom widget)

How can I use form_for to generate this and still have each row styled
by the FormBuilder of my choice? Do I need to extend each FormBuilder
with all of the methods that I might want to use?

I’ve been using the FormBuilders listed in the Rails Recipes book as
well as the LabeledFormHelper from techno-weenie.net

Speaking of LabeledFormHelper, this is listed in its README file:


<% form_for :person, @person, :url => { :action => “update” } do |f|
%>
First name: <%= f.text_field :first_name %>
<% end %>

First Name

---------

Can it really detect the random text “First name:” and wrap it in a
label? Seems unlikely to me.

Thanks,

-Eli Gordon

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs