[Catalyst] Forms generation
Leo Cacciari
leo.cacciari at gmail.com
Thu Jun 14 10:34:52 GMT 2007
Hi,
I'd like to ask the list wisdom for a somehow philosophical problem
connected with this mail subject.
Let us start by considering the CURD example contained in
Catalyst::Manual::Tutorial::AdvancedCRUD. In this example, the user
enters his or her data using a form generated by the controller using
HTML::Widget. While this approach presents the non negligible advantage
to allow easy validation of entered data, and even automatic population
of a database object, it has IMHO a problem in making the controller
aware of things that should be known only to the view, namely how to
actually compose the form in HTML, or even that a HTML form should be
used at all (what if I want to use something like Catalyst::View::Wx for
my user interface generation?).
As I see it, the controller should tell the view 'I want the user
entering the following data, each one with its data-type, and obeying
the following constraints". But it is not the work of the controller to
say _how_ the form should be presented to the user. Just as an example,
if the user is supposed to choose one among several alternatives, it is
a view decision if present the user with a drop down list, or a list of
radio buttons. The only thing the controller is interested in, is that
one, and only one among the proposed alternatives is chosen by the user.
What I'd like, is to have the controller generate a "generic user
interface form object" and pass it to the view. The view would the use
the object to generate the actual form presented to the user.
On reception of the request, the controller would have to find the
object filled up with the user entered data (using some plugin[1]), and
be able to check the constraints (via some "verify" method), and maybe
use the object for actually filling a database object.
What do the list members thinks about this? How do you generate your
forms? Is there something like this already out, and I'm to stupid to
find it?
Note:
[1] Yes,I know that plugins are discouraged, but for maintaining the
'View and Model agnosticism of Catalyst, filling the object from the
request data can not be a method of the form object.
--
Leo "TheHobbit" Cacciari
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Questa =?ISO-8859-1?Q?=E8?= una parte del messaggio
firmata digitalmente
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070614/44a91a4b/attachment-0001.pgp
More information about the Catalyst
mailing list