Q: ActiveForm?

Steve Ross
2005-11-09T20:40:16Z

This question pops in and out of the mailing list and I''m wondering
whether
others have solved it. Consider the case where the user is filling out a
form but there is no underlying database record (say the contents of the
form are emailed someplace then discarded).

It would be great to use:

<%= text_field(:my_fine_form, ''last_name'') %><br
/>
<%= text_field(:my_fine_form, ''first_name'') %>
# etc.

Then have params[:my_fine_form] automagically populate some object just as
it does the model. E.g.,

@my_fine_data = MyFineForm.find()	# populates from
params[:my_fine_form]
redirect_to :action => ''entry_form'' unless
@my_fine_data.valid?

And even cooler, a form model:

def MyFineForm < ActiveForm
	:validates_presence_of :last_name
	:persists_in_session => true;
#	and blah, blah, blah
end

I''d write this myself -- I may even have to -- but I wanted to make
sure
nobody else already has.

Thanks