Proposed new module : CGI::FormManager 
Author Message
 Proposed new module : CGI::FormManager

Hi everyone,
I've got a module I've been working on and tweaking for quite a while, and
I'm planning on uploading it to CPAN as soon as I have the whole MakeMaker
thing figured out.  Unless there are any objections, I'd like to claim the
name CGI::FormManager as my very own.

I'd also like to hear the opinions of the perl community on this one.  I've
looked around and haven't found anything that I'm happy with that does what
this module does.  It's a sort of meeting point between the basic html
support in the CGI module and the templating of HTML::Template.

This module has proven very useful to me.  It's excellent at creating
quick'n'dirty forms, or relatively long forms such as user registration.  
The basic premise is that you build a form using "Components".  These
components can be basic form elements such as select boxes and radio
buttons, but can also be combinations.  For instance, one could create a
component composed of three select boxes for Month, Day, Year, and treat it
as a single input.

Once a form is created, it can produce the html for the form
(<FORM>...</FORM>), or for the entire page (<HTML>...</HTML>) if you're
lazy.

When the user fills in the form, a FormManager automatically validates the
input and puts the response into the desired form (for instance, the date
component suggested above could return a timestamp rather than a string).  
If an invalid value is received, or if a required field is left blank,
FormManager remembers all of the old values and will fill them in for you
when you send the form back to the user.

Anyway, Thanks for the input.  I'll leave you with some example code.
James

Example
================================================
use FormManager;

my $query = new CGI();

# CREATE THE FORM
my $fm = new FormManager
  (layout =>
    [new FormManager::Text
        (name => 'phone_number',
        heading => 'Enter your phone number',
        validate => 'phone'),

    new FormManager::Select
        (name => 'likes_ice_cream',
        heading => 'Do you like ice cream?',
        option_list => ['Yes', 'No']),

    new FormManager::Hidden
        (name => 'action',
        value => 'submit_this_form')
  ],
  form_submit => 'Submit this form'
);

print "Content-Type: text/html\n\n";

# This script can be called in two ways
# 1) Initially to get the form
# 2) By submitting the form

# If this is case 1)
if ($query->param ('action') ne 'submit_this_form') {
  print $fm->getHtml();

Quote:
}

else {
  # Ensure that the input is valid.  If not, re-print the form
  if (!$fm->processQuery()) {
    print $fm->getHtml();
  }
  else {
    print "Your phone number is : " . $fm->getValue ('phone_number')" .
" and you " . ($fm->getValue ('likes_ice_cream') eq 'No' ? "don't like ice
cream." : "like ice cream.");
  }
Quote:
}



Sat, 24 Sep 2005 04:49:52 GMT  
 Proposed new module : CGI::FormManager

Quote:

> I've got a module I've been working on and tweaking for quite a
> while, and I'm planning on uploading it to CPAN as soon as I have
> the whole MakeMaker thing figured out.  Unless there are any
> objections, I'd like to claim the name CGI::FormManager as my very
> own.

Hi James,

Thanks for letting us know about your module.

When reading your description of it, I can't help thinking of
CGI::FormBuilder. If you have studied that module, could you please
brief us about the distinction between CGI::FormBuilder and
CGI::FormManager.

/ Gunnar

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



Sat, 24 Sep 2005 07:05:04 GMT  
 Proposed new module : CGI::FormManager

Quote:


>> I've got a module I've been working on and tweaking for quite a
>> while, and I'm planning on uploading it to CPAN as soon as I have
>> the whole MakeMaker thing figured out.  Unless there are any
>> objections, I'd like to claim the name CGI::FormManager as my very
>> own.

> Hi James,

> Thanks for letting us know about your module.

> When reading your description of it, I can't help thinking of
> CGI::FormBuilder. If you have studied that module, could you please
> brief us about the distinction between CGI::FormBuilder and
> CGI::FormManager.

> / Gunnar

I haven't used the FormBuilder module, but I've read through the
documentation.  Aside from the fact that FormBuilder is polished and
FormManager is beta :)  I think that the main difference between the two is
extensibility.  It's quite easy to add a new component and validation into
the existing code for FormManager.  I found myself using certain groups of
fields quite often, and that was one of the first motivating factors for
FormManager.

For instance, I've written a component for a dynamic select box.  It
involves a select box, "Add", "Remove", and "Edit" buttons, and textboxes
where the user can input data.  It's useful for fields where you don't know
how many the user will need.  (e.g. rather than text fields for
group_member1, group_member2, ... have all of them added to this select
box)

Ideally there will eventually be a large number of such components, making
complex form constructs much easier to use.

James



Sat, 24 Sep 2005 07:45:24 GMT  
 Proposed new module : CGI::FormManager

Quote:


>>When reading your description of it, I can't help thinking of
>>CGI::FormBuilder. If you have studied that module, could you please
>>brief us about the distinction between CGI::FormBuilder and
>>CGI::FormManager.

> I haven't used the FormBuilder module, but I've read through the
> documentation.  Aside from the fact that FormBuilder is polished and
> FormManager is beta :)  I think that the main difference between the two is
> extensibility.  It's quite easy to add a new component and validation into
> the existing code for FormManager.  I found myself using certain groups of
> fields quite often, and that was one of the first motivating factors for
> FormManager.

> For instance, I've written a component for a dynamic select box.  It
> involves a select box, "Add", "Remove", and "Edit" buttons, and textboxes
> where the user can input data.  It's useful for fields where you don't know
> how many the user will need.  (e.g. rather than text fields for
> group_member1, group_member2, ... have all of them added to this select
> box)

> Ideally there will eventually be a large number of such components, making
> complex form constructs much easier to use.

Sounds interesting. Provided that you have considered the option to
try to have the additional functionality of your module added to e.g.
CGI::FormBuilder, and still find it 'right' to add another form module
to CPAN, I'm looking forward to your announcement. :)

/ Gunnar

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



Sat, 24 Sep 2005 07:51:04 GMT  
 Proposed new module : CGI::FormManager
James Beninger wrote (Monday 07 April 2003 22:49):

Quote:
> Hi everyone,
> I've got a module I've been working on and tweaking for quite a while, and
> I'm planning on uploading it to CPAN as soon as I have the whole MakeMaker
> thing figured out.  Unless there are any objections, I'd like to claim the
> name CGI::FormManager as my very own.

> I'd also like to hear the opinions of the perl community on this one.
> I've looked around and haven't found anything that I'm happy with that
> does what
> this module does.  It's a sort of meeting point between the basic html
> support in the CGI module and the templating of HTML::Template.

> This module has proven very useful to me.  It's excellent at creating
> quick'n'dirty forms, or relatively long forms such as user registration.
> The basic premise is that you build a form using "Components".  These
> components can be basic form elements such as select boxes and radio
> buttons, but can also be combinations.  For instance, one could create a
> component composed of three select boxes for Month, Day, Year, and treat
> it as a single input.

> Once a form is created, it can produce the html for the form
> (<FORM>...</FORM>), or for the entire page (<HTML>...</HTML>) if you're
> lazy.

> When the user fills in the form, a FormManager automatically validates the
> input and puts the response into the desired form (for instance, the date
> component suggested above could return a timestamp rather than a string).
> If an invalid value is received, or if a required field is left blank,
> FormManager remembers all of the old values and will fill them in for you
> when you send the form back to the user.

> Anyway, Thanks for the input.  I'll leave you with some example code.
> James

It looks to me like you are trying to reinvent the wheel. FormBuilder does
all your module describes and even more easy. It will even try to suggest
the element type: check box, edit box, drop down list, mutli-select, etc.
In the two years I've used it, it didn't guess wrong once.  Also,
FormBuilder does field validation with a ton of predefines. This means
FormBuilder forms can be cut down to the minimum without loosing anything.
I am not saying that you shouldn't persue with your work. But at this
point, I am not clear what the benefits of your module are over
FormBuilder.

--
KP



Sat, 24 Sep 2005 14:19:53 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. proposed API for new MIDI module

2. Propose new module HTML::Table

3. Proposing a new module: Parallel::Loops

4. New module proposed: Class::Accessor::NoviceArray

5. Data::Validator - proposed new module

6. New module proposed: Class::Accessor::NoviceArray

7. Proposing 2 new modules for CPAN

8. new proposed module: Sys::UniqueInstance

9. Proposed New Module: WWW::BBSWatch

10. Proposed new module Sort::Indices

11. New module ASP::CGI ( ASP.cgi )

12. Proposed new Usenet group forBerkeley DB

 

 
Powered by phpBB® Forum Software