The best forms ever!
posted by ryan on April 13th, 2007
So a big requirement for FACTOR is that the application forms are easy to modify as they change from year to year. So I tasked Hampton with creating a form builder that would allow me as a PM to add/delete and edit the forms quickly and easily. What he came up with is pretty awesome.
So a big requirement for FACTOR is that the application forms are easy to modify as they change from year to year. So I tasked Hampton with creating a form builder that would allow me as a PM to add/delete and edit the forms quickly and easily. What he came up with is pretty awesome.
You can easily define what type of field it needs to be followed by the database field name:
form.field :fieldname # Input Text form.select :fieldname # Combo form.yes_or_no :fieldname # Boolean form.text_area :fieldname # Multi Line Input form.number :fieldname # Input Number
You can then add an arbitrary list of additional attributes. If you don’t specify a name, it will use the fieldname and apply a format. For example, :contact_phone becomes “Contact Phone”.
You can also specify a label manually, and a default value:
:label => 'Label Name' :default_value = 'Canada'
For combo-boxes, you can specify the options:
:select_options => ["Performer", "Label"]
You also can specify a tooltip:
:tip => "Don't forget to include your area code eg: 416-898-0909"
You even specify the formatting for validation:
:format => :date :required = > true
So this…
form.field :artist_name, :required => true, :label => "Artist Name" form.field :artist_website, :label => "Artist Website", :default_value => "http://", :tip => "By providing your web address you agree to a link between FACTOR's website and the artist's. The link will be created should your application be approved for funding."
Renders like this..

The form controls the database!
And what makes it even cooler is that the form actually controls the database so if I needed to add a new field to ask if the Artist is Canadian, I simply add this to the form.
form.yes_or_no :artist_is_canadian, :label => "Is the artist/group Canadian?"
And the next time that page is loaded a boolean field called artist_is_canadian will be magically added to the database….tada!
This gives me the ability to control the entire application through one interface and reduces the amount of code I need to sift though when changes are required. Since we launched the app last week it has been a huge time saver.
April 18th, 2008 at 04:20 AM
mailguard codivine undutiable abomine unprecise autotomic insula proctodynia THERAPY 2000 http://www.cepelia.pl/