In FormHandler the connection with dabase layer (called Model) is done
with a role - for example HTML::FormHandler::Model::DBIC.  But the
functionality provided there fits into more than one class (for
example it needs to be added to both the main form class and the
individual field classes).  I imagine this is not an uncommon
situation that you need a role that would add features to a whole
class hierarchy and my question is what is the common practice here.

In FormHandler the role used to add only methods to the form class -
this was leading to awkward things like:

$field->form->lookup_options( $field, ... )

I added a new hook (model_new_field_hook) in the BUILD method of the
Form and individual Fields where I injected the needed traits.  The
change is at: 
http://github.com/gshank/html-formhandler-model-dbic/commit/f60aa50b5b7a0ae3f37af27e06d22d5e47f33902
and 
http://github.com/gshank/html-formhandler/commit/40933e98c68e3d5169b612743c877cbc578b6a4e

What do you think about it?

-- 
Zbigniew Lukasiak
http://brudnopis.blogspot.com/
http://perlalchemy.blogspot.com/

Reply via email to