in reply to Is there room for YAHTMLM?

General comments:
The getHTML() method is okay to have, but what you will probably want is a getform() method (or getHTMLform() perhaps) that returns only the part from <form up through </form>. That allows multiple forms on the same page (only one of which will be submitted at any time, of course -- each form can have a hidden input that indicates which form it is, to prevent any ambiguity), arbitrary additional content, and, in general, more flexibility. Make sure your form html is wellformed xhtml, too. Ideally it should validate.

For instance, one could create a FormManager::Date component which consists of three select boxes for month/day/year. In your code, you could treat this as a single input.

That sounds to me like it ought to be included (eventually), because it would be a generally useful feature. Bonus points if it has separate methods to return the date in MySQL format or the way localtime does, depending on what the calling code is going to do with the data.

Validation

That alone, IMO, makes it worth having in addition to CGI. Your methods for getting the form input could internally rely on CGI.pm if it will do what you need, but putting the validation layer on top is a significant improvement. If there's not another well-done module out there that handles this, then yours would be a Good Thing.

To go a little further with that... on failure, it ought to generate a reference (to a hash or something; the internal implementation is unimportant, since it can be treated by the calling code as a magic token) that can be retrieved by the calling code and passed to the next call to getHTMLform() (or whatever) to cause the sections of the form relevant to the failure to be marked up with a "validationfailure" class, so that the calling code can easily style them with a red outline or somesuch.


for(unpack("C*",'GGGG?GGGG?O__\?WccW?{GCw?Wcc{?Wcc~?Wcc{?~cc' .'W?')){$j=$_-63;++$a;for$p(0..7){$h[$p][$a]=$j%2;$j/=2}}for$ p(0..7){for$a(1..45){$_=($h[$p-1][$a])?'#':' ';print}print$/}

Replies are listed 'Best First'.
Re: Re: Is there room for YAHTMLM?
by jbeninger (Monk) on Mar 01, 2003 at 22:24 UTC
    Actually, there already is a getForm() function. I've also included a FormManager::Html component for people who just want a quick and dirty way of making a form, or want to include arbitrary html between the fields.

    On the Date component - the plan is to make it have options for begin/end time (only show 2001-2010, for instance), different date formats, etc. Eventually I'd like all components to be as flexible as possible in terms of how information is handled, but as far as the actual display goes, I'd like to force the user to use stylesheets. Right now I'm still working on fleshing the whole thing out (radio buttons aren't implemented, for instance).

    On validation - right now the default is to display errors if validation fails. It's pretty basic right now : "Field : 'Car Speed' must be a number". Errors are displayed in red at the top of the field. There's also an option to suppress them or simply retrieve them as an array if so desired.

    Anyway, thanks for the feedback and suggestions.
    James

      Sounds like you're a step ahead of me :-)