Mark Paxton
2005-May-03 20:14 UTC
How to put a form for one controller in another controlers view
Hello, If anyone could help me out with this problem I''d appreciate it... I''m making a database of event bookings, I have an events table and a clients table. I''d like to include a form to create a new client in the form for creating a new event. This would update the parent form with the new client_id using AJAX methods (see previous e-mail) so you''d never have to leave the ''new booking'' page to add a new client. I''m not entirely sure how to render the form that''s part of the client controller in the ''new event'' view. I''d like to keep it sensible and have it reusable in the client controller, not just hard coded into the new event view. Thanks for the help! Mark
Dee Zsombor
2005-May-04 07:15 UTC
Re: How to put a form for one controller in another controlers view
Hi! Perhaps you could implement new_client form inside view/shared/_newclient.rhtml or something similar. Then you could call render_partial on "shared/newclient" when adding events. Cheers, Zsombor On 5/3/05, Mark Paxton <mark-LgYV4FD66f9DpWgnxyDo8Q@public.gmane.org> wrote:> Hello, > > If anyone could help me out with this problem I''d appreciate it... > > I''m making a database of event bookings, I have an events table and a > clients table. I''d like to include a form to create a new client in the > form for creating a new event. > > This would update the parent form with the new client_id using AJAX > methods (see previous e-mail) so you''d never have to leave the ''new > booking'' page to add a new client. > > I''m not entirely sure how to render the form that''s part of the client > controller in the ''new event'' view. I''d like to keep it sensible and > have it reusable in the client controller, not just hard coded into the > new event view. > > Thanks for the help! > > Mark > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- http://deezsombor.blogspot.com
Brian L.
2005-May-04 16:26 UTC
Re: How to put a form for one controller in another controlers view
If the form needs controller-type setup (initializing a blank object, etc), then you could look at components--make an action on the relevant controller that initializes data and then does render_partial ''controller/form_partial'' and then use render_component :controller=>''controller'',:action=>''form_partial_action'' to drop it in. Have a look at the components book on heiraki. It''s brief, but I think it can do what you want. Brian On 5/4/05, Dee Zsombor <dee.zsombor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi! > > Perhaps you could implement new_client form inside > view/shared/_newclient.rhtml or something similar. Then you could call > render_partial on "shared/newclient" when adding events. > > Cheers, > Zsombor > > On 5/3/05, Mark Paxton <mark-LgYV4FD66f9DpWgnxyDo8Q@public.gmane.org> wrote: > > Hello, > > > > If anyone could help me out with this problem I''d appreciate it... > > > > I''m making a database of event bookings, I have an events table and a > > clients table. I''d like to include a form to create a new client in the > > form for creating a new event. > > > > This would update the parent form with the new client_id using AJAX > > methods (see previous e-mail) so you''d never have to leave the ''new > > booking'' page to add a new client. > > > > I''m not entirely sure how to render the form that''s part of the client > > controller in the ''new event'' view. I''d like to keep it sensible and > > have it reusable in the client controller, not just hard coded into the > > new event view. > > > > Thanks for the help! > > > > Mark > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > -- > http://deezsombor.blogspot.com > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- The years ahead pick up their dark bags. They move closer. There''s a slight rise in the silence then nothing. -- (If you''re receiving this in response to mail sent to bluczkie-OM76b2Iv3yLQjUSlxSEPGw@public.gmane.org, don''t be concerned This is my new address, but mail will be forwarded here indefinitely)