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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A7f6b372a89349258d08a4d7acb186d4?d=identicon&s=25 Serengeti (Guest)
on 2007-07-27 19: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.

Thanks!
Errol
0f0653be00d92cce9db83daccb6de3fb?d=identicon&s=25 cunheise (Guest)
on 2007-07-27 19:43
(Received via mailing list)
maybe you are right cos django is separate model and form builder
A7f6b372a89349258d08a4d7acb186d4?d=identicon&s=25 Serengeti (Guest)
on 2007-07-30 22: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?
A7f6b372a89349258d08a4d7acb186d4?d=identicon&s=25 Serengeti (Guest)
on 2007-08-01 18:51
(Received via mailing list)
So, has anybody used a custom form builder?
9347d4d9f9c4272f6a3297ea3a5976ac?d=identicon&s=25 Kip (Guest)
on 2007-08-02 02: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.