# Newbie question: Dynamic view creation from obj.to\_html\_form

**URL:** <https://www.ruby-forum.com/t/newbie-question-dynamic-view-creation-from-obj-to-html-form/56096>\
**Category:** Rails\
**Created:** [March 28, 2006, 6:12am UTC](https://www.ruby-forum.com/t/newbie-question-dynamic-view-creation-from-obj-to-html-form/56096 "2006-03-28T06:12:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miles\_Monroe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58956e/32.png) [@Miles\_Monroe](https://www.ruby-forum.com/u/Miles_Monroe)\
**Post date:** [March 28, 2006, 6:12am UTC](https://www.ruby-forum.com/t/newbie-question-dynamic-view-creation-from-obj-to-html-form/56096/1 "2006-03-28T06:12:39Z")

</div>

Hi. I would like to be able to generate a form dynamically from an  
object’s to\_html\_form method, submit it, and then place marshalled  
object into a database row.

Since I do not know exactly all the input fields in advance, I figure  
this would allow me to dynamically create the input form, stuff the user  
input into object, marshal the object into the database, and display it  
later dynamically for the user to edit again.

I actually need to use the composite design model and so I will perhaps  
have nested objects with form information. I should be able to marshal  
and unmarshal these objects without difficulty.

How do I do this in Rails? This would be pretty cool because I could  
all sorts of objects and their associated forms in the same table. I  
could have a column for class name to iterate through all the same  
objects that I am interested in.

Thanks.

---

<div class="post-metadata">

**Author:** ![Miles\_Monroe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58956e/32.png) [@Miles\_Monroe](https://www.ruby-forum.com/u/Miles_Monroe)\
**Post date:** [March 28, 2006, 9:24am UTC](https://www.ruby-forum.com/t/newbie-question-dynamic-view-creation-from-obj-to-html-form/56096/2 "2006-03-28T09:24:57Z")

</div>

Miles Monroe wrote:

> Hi. I would like to be able to generate a form dynamically from an  
> object’s to\_html\_form method, submit it, and then place marshalled  
> object into a database row.
> 
> Since I do not know exactly all the input fields in advance, I figure  
> this would allow me to dynamically create the input form, stuff the user  
> input into object, marshal the object into the database, and display it  
> later dynamically for the user to edit again.
> 
> I actually need to use the composite design model and so I will perhaps  
> have nested objects with form information. I should be able to marshal  
> and unmarshal these objects without difficulty.
> 
> How do I do this in Rails? This would be pretty cool because I could  
> all sorts of objects and their associated forms in the same table. I  
> could have a column for class name to iterate through all the same  
> objects that I am interested in.
> 
> Thanks.

OK, I found the “Making Dynamic Templates” section in Agile Web  
Development with Rails. I think that should explain it. Has anyone  
created a dynamic template?

Thanks.
