[Catalyst] Putting more in the View

Ian Docherty icd at ecisecurity.com
Thu Feb 16 12:19:08 CET 2006


Bill Moseley wrote:

>...
>
>That sets a "form" stash variable.  $form->item has the user's object
>(unless creating).  So that's available in the template.
>
>$form->fields has the list of fields for accessing all the fields, and
>$form->field('status') is one of the fields in the form (that happens
>to be a radio select).  My form elements know what type they are
>(text, select, multiple select) and know how to generate the html for
>the field.
>
>$form->fif returns a hash usable for HTML::FillInForm.  $form->fif
>returns either the initial data form looking up the object or the
>request parameters passed in to the update_from_form() method.  That
>makes the form sticky. ...
>
>  
>
I wrote a long reply to this which I did not post but it helped me to
understand much better what you are doing. My summary is:-

FillInForm will allow me to replace my own implementation of sticky-forms.

FormValidator will help me to make my form validation code cleaner. (I
still need to research this more).

I gather that you are doing the database insert and update (via ORM) in
your Form class? I can't decide if this is good or bad. It hides some of
the business logic in a class and it is not so easy to see the logic in
the controller.

However I like the idea of simplifying the Controller. That is what I
was aiming towards. What you do however is to hide much of the
complexity in the Form class (which is no bad thing). However much of
the complexity still remains.

For example. You still have to convert from the User object into a flat
hash to pass it to the FillInForm.
You still have to convert from the request params into the User object
to save it in the database.

We don't disagree that these need to be done. It is just that I was
(note the past tense) doing it in the the View, you are doing it in a
Form class.

One final request. It would help me greatly if I could see an example of
your WS2::Form::Admin::Person class. I am still unsure how you have
implemented it (as a Plugin for example, or how you have implemented the
$c->form_posted method).

Thanks for your help
Ian








More information about the Catalyst mailing list