I've recently deleted lot's of code from InstantCRUD - some logic moved to templates, some to HTML::Widget::DBIC, some just simplified (with the help of uri_with). I am feeling the code for CRUD becomes quite 'elegant'.
What I am still not happy with is the widget config - I feel that all the visual things (like the choice between textarea and textfield etc) should be managed in the templates. The Ruby on Rails helpers seem ideal solution - they do all the validation, filling up the values that need to be done in the controller, but let the View manage the actual HTML produced. To reach that we would have be able to produce HTML::Widget::Element without specifying that it is to be a textfield or a radio box and leave the HTML generation to be called in the template, something like:
[% result.field_html('fieldname, 'textarea', cols, 30, rows, 5) %]
This would produce the field html with the proper value and an error mark if there was an error during validation. This looks like too radical step for evolution of HTML::Widget - perhaps what is needed is some completely new module?
Inspired by "Rails-like form helpers" email discussion.
There is a reply at the mailing list.
Friday, October 20, 2006
Subscribe to:
Post Comments (Atom)
2 comments:
Yes, I agree with you. HTML::W is a great tool, but it's not so good for the auto generated code. People, especially in Perl community, want greater control of their code. I'd like to be able to move form elements around and do forms "my own way".
I've edited H::W, to make it possible to add a 'Field' type element to achieve this.
$widget->element(Field => foo);
$result->field_xml( foo => 'Textfield', %attrs );
which could of course be called from TT with:
result.field_xml( foo, Textarea, cols, 30, rows, 5 )
I haven't committed it to svn yet though, as I'd like to get some feedback first on what other sort of features you'd like, as I'm guessing some might require architectural changes.
btw, are you subscribed to the h-w mailing list? I sent a response to this blog post to the list last week. If you want to discuss this further, I'd much rather see the conversation happen there, where other h-w contributors hang out.
Carl Franks
Post a Comment