ActiveForm plugin

Published at: 24.IX.2007 21:49 CET
Categories: active_form, english, plugin, rails

Last week at RailsConf Europe I met some people who are using my ActiveForm code to make forms in their Rails sites. It’s about time to wrap it up as a plugin, so here it is.

From the README:
This plugin provides a base class for making forms with ActiveRecord validations without having a corresponding database table. You can use ActiveForm for:
  • making forms which don’t needed storage, like simple email forms
  • provide extra validations on existing ActiveRecord models
  • make forms for composite objects
Installation:
script/plugin install http://svn.remvee.net/plugins/active_form

I know, there already is a plugin called active_form but I don’t like it. It doesn’t provide a “real” AR object causing all kinds of things to not work (like ActiveRecordHelper#form and DateHelper#datetime_select for instance), it doesn’t include any tests and my version is a lot simpler (flog score 20 versus 74).

Why not change the name? I like it! If you can come up with something better, please leave a comment.

p3t0r @ about 11 hours later

Probably just being pedantic here, but I noticed your active form plugin is based upon ‘columns’ whereas this doesn’t seem correct to me if one is not talking about tabular data.

Why didn’t you go for the (IMHO) more obivious ‘fields’ solution?

Remco @ about 12 hours later

The column method actually adds columns to the object. Changing the method name to field means I should provide aliases to all column related methods like column_names and columns_hash.

Note, it still is an ActiveRecord object! It has a database connection, the save method is protected by an transaction and other goodies are still in place.