Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Choosing a Catalyst form widget

by phaylon (Curate)
on Apr 17, 2007 at 13:34 UTC ( #610519=note: print w/ replies, xml ) Need Help??


in reply to Choosing a Catalyst form widget

Disclaimer: This is all just IMHO and personal experiences. Other solutions might be more suitable for other environments.

I have used HTML-Widget in the past, but I was always concerned with the fact that my controller defines the interface. I'm now using a self made controller base class doing configurable CRUD (not auto-detected). This is essentially it:

  • The form is organised and built with CGI-FormBuilder
  • The validation is done with Data-FormValidator
  • The controller base class reads its configuration as well as the fields from a YAML file that is loaded by the controller itself, since the YAML like source file for FB looks like YAML, but isn't really.
  • The controller also does the I18N
  • I don't use FB's native rendering facility, but walk the configured fields in a custom Template-Toolkit file that applies more general stylesheets, AJAX hooks, error and success messages.

HTH, phaylon

PS: I use DBIx::Class exclusively these days, at least for non-legacy projects.


Ordinary morality is for ordinary people. -- Aleister Crowley


Comment on Re: Choosing a Catalyst form widget
Replies are listed 'Best First'.
Re^2: Choosing a Catalyst form widget
by mattr (Curate) on Apr 17, 2007 at 16:23 UTC
    Thanks. I started trying Catalyst::Controller::FormBuilder. I was stunned at how the YAML file suddenly made this beautiful form appear, with a JavaScript error message popping up; that alone is worth it perhaps. However I think the docs are a bit lacking, or maybe my first use of it is not one that is intended (first is a static form not based on an object in the database). Also I can't get css to target the form correctly.. Also I'm not quite sure if it is possible to get C::C::FB to render the form contents without editable fields, like a confirmation page, though it is not a deal-breaker. Probably rolling my own template would solve some of these issues..

    Also thanks for the tip, I didn't realize it isn't really YAML they're using, though they do say "essentially YAML".

    Also I found the pod code doesn't work for the simple static form I am making now that does not depend on the database; I think the edit() subroutine is not supposed to be used in this case perhaps. Just display cyclically with view() and then forward to save(). That is, the /edit url makes no form show, while the /view url displays an editable table. Perhaps edit() is meant to only work with a database object i.e. edit book id 5 with /edit/5, like in the CRUD tutorial.

    I'll keep at it, but I'm a bit worried that the /view url is showing an editable form. I'd think /view should only display existing data not as an input form at all... but if so then will have to roll my own confirmation page template I suppose. Hmm, maybe I need to make a dummy module to site in the DB directory that holds my DBIx::Class? I didn't make this one using the catalyst_create.pl script, maybe this is the problem?

    UPDATE: Successfully made a static form with Catalyst::Controller::FormBuilder. Only required defining fields in edit.fb, creating /view and /save subroutines, and creating templates for /view (which is about 1 line), /save (a for loop with table rows of field.label and field.value), and /error (dupe user name, etc. a stashed message). I think I'll see how this works out for the next stage of my project, too.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://610519]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (14)
As of 2015-07-28 19:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls