[Catalyst] Forms generation

Strader, Andrew astrader at iccohio.com
Thu Jun 14 15:31:22 GMT 2007


You should check out the FormValidator plugin, which is built on top of Dat=
a::FormValidator. It lets you specify a profile for request parameter valid=
ation and passes back a results object, which contains the validated values=
 of parameters or their status otherwise (missing, invalid).

________________________________

Date: Thu, 14 Jun 2007 11:34:52 +0200
From: Leo Cacciari <leo.cacciari at gmail.com>
Subject: [Catalyst] Forms generation
To: The elegant MVC web framework <catalyst at lists.rawmode.org>
Message-ID: <1181813692.5744.41.camel at legolas>
Content-Type: text/plain; charset=3D"us-ascii"

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/ms-tnef
Size: 5056 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070614/6c70=
411b/attachment.bin


More information about the Catalyst mailing list