Creating a Dynamic/Custom form

I am pretty new at rails and seem to be stuck on an issue.

Trying to find a way to get me app admin to create a form on our rails
app. These would include:

  • Select form control type
  • Select required validation
  • Select price change if selected

How should I even start going at this?

On 10 January 2011 14:46, RogerM [email protected] wrote:

I am pretty new at rails and seem to be stuck on an issue.

Trying to find a way to get me app admin to create a form on our rails
app. These would include:

  • Select form control type

What is a form control type?

  • Select required validation

What does that mean

  • Select price change if selected

Don’t understand that either, sorry.
In fact I don’t understand what you mean by the app admin creating a
form.

Colin

What is a form control type?

  • Select required validation

What does that mean

  • Select price change if selected

Don’t understand that either, sorry.
In fact I don’t understand what you mean by the app admin creating a form.

Hi Colin, sorry I am probably not using proper terminology. I have a
subdomin type rails application. I am trying to get the administrator
users of the subdomain account to create an HTML form, something
similar to phpform.org.

Roger

Can anyone shed some details or point me in the correct direction?

In a nutshell I am trying to get the users in my app to create and use
web forms. I found a great jQuery example, I just have no idea how-to
save the form structure to db then render it and saving users answers/
options to the rendered form.

Roger

Not sure if it’s the best way, but here’s an idea. For each custom form,
use some combination of serialized db fields (one to hold the form
meta-data (field-types, field names, etc.) and a corresponding field to
hold the data.

Garrett L.

Garrett L. wrote in post #975922:

Not sure if it’s the best way, but here’s an idea. For each custom form,
use some combination of serialized db fields (one to hold the form
meta-data (field-types, field names, etc.) and a corresponding field to
hold the data.

If you’re using a relational database, I think it would actually be
better to have Form, Field, ValueSet, and Value models (and associated
tables):

class Form < AR::B
has_many :fields
has_many :records

class Field < AR::B
belongs_to :form
has_many :values

class Record < AR::B
belongs_to :form

maybe belongs_to :user or something

has_many :values

class Value < AR::B
belongs_to :field
belongs_to :record

(Record is my ad-hoc term for one user’s response, filling in all form
fields. There may be a better name. Also, some :throughs in there may
make life easier, depending on the use case.)

This might be a good candidate for a non-relational solution such as
MongoDB.

Garrett L.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Marnen Laibow-Koser wrote in post #975923:

Garrett L. wrote in post #975922:

Not sure if it’s the best way, but here’s an idea. For each custom form,
use some combination of serialized db fields (one to hold the form
meta-data (field-types, field names, etc.) and a corresponding field to
hold the data.

If you’re using a relational database, I think it would actually be
better to have Form, Field, ValueSet, and Value models (and associated
tables):

Er, sorry. I changed ValueSet to Record and missed that instance.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

On Jan 18, 9:12pm, Marnen Laibow-Koser [email protected] wrote:

If you’re using a relational database, I think it would actually be
better to have Form, Field, ValueSet, and Value models (and associated
tables):

Thanks I am going to give that a try.

Marnen Laibow-Koser wrote in post #975923:

If you’re using a relational database, I think it would actually be
better to have Form, Field, ValueSet, and Value models (and associated
tables)
I would agree, especially if you’re going to use this concept in a
variety of circumstances. If it’s just one customization on one model
then I might be inclined to go the other way in some cases. Debatable.

Garrett L.