Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

We're using Catalyst to render lots of webforms in what will become a large application. I don't like the way all the form data is confusingly into a big hash in the Controller, before being passed to the template. It seems jumbled up and messy for the template. I'm sure there are real disadvantages that I haven't described properly... Are there?

One solution is to just decide on a convention for the hash, e.g.:

{
  defaults => {
    type => ['a', 'b', 'c']
  },
  input => {
    type => 'a'
  },
  output => {
    message => "2 widgets found of type a",
    widgets => [ 'foo', 'bar' ]
  }
}

Another way is to store the page/form data as attributes in a class (a ViewModel?), and pass a whole object to the template, which it could use like this:

<p class="message">[% model.message %]<p>

[% FOREACH widget IN model.widgets %]

Which way is more flexible for large applications?

Are there any other solutions or existing Catalyst-compatible frameworks?

share|improve this question

1 Answer 1

HTML::FormHandler can render forms for you, using either the Simple or Table built in renderers. But you're not forced to use them. You can write your own, or leave them all out together (which is what I did, though I doubt that was a good decision). I've found it to be a very flexible module (it being built with Moose). You can also let it handle saving the data to the database with HTML::FormHandler::TraitFor::Model::DBIC, or roll your own.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.