Forum: Ruby on Rails Learning how to use custom Form Builders

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Serengeti (Guest)
on 2007-07-27 21:27
(Received via mailing list)
I worked my way through the FormBuilder example in the Agile Web
Development With Rails book, but I now have some questions about
applying this idea to other situations.

The example seems to work well for the case where I am using form_for
to have a single form with fields that relate to attributes of a
particular model.

How can I use my custom FormBuilder for other situations?  Examples:

1. Non-model fields added to form_for model form.
2. Fields for other models added using fields_for.
3. Non-model fields used for non-model forms (just using form_tag)

It seems like the main benefit of using a custom FormBuilder is to
enforce a consistent look across forms.  It would be great to extend
this to include all my forms, not just model-based forms.

cunheise (Guest)
on 2007-07-27 21:43
(Received via mailing list)
maybe you are right cos django is separate model and form builder
Serengeti (Guest)
on 2007-07-31 00:57
(Received via mailing list)
On further inspection, it looks like I can specify a builder with
fields_for.  That still leaves case #1 and case #3 (see above).  Does
anybody have any thoughts on this?
Serengeti (Guest)
on 2007-08-01 20:51
(Received via mailing list)
So, has anybody used a custom form builder?
Kip (Guest)
on 2007-08-02 04:12
(Received via mailing list)
Yes, and its been a big productivity boost once i worked out how to
apply to html wrappers to form fields in the way i wanted.  However,
like you, i would like to use if for non-model forms and for
fields_for forms.  I haven't put that high enough on the priority list
to investigate, although i did note that fields_for is in the context
of form_for so I suppose there is some hope there - but I don't know
how to get under the covers of fields_for.

Cheers, --Kip
This topic is locked and can not be replied to.