fmII
Thu, Aug 21st home | browse | articles | contact | chat | submit | faq | newsletter | about | stats | scoop 11:27 UTC
in
Section
login «
register «
recover password «
[Project] add release | add branch | add screenshot | broken links | change owner | email subscribers | update project | update branch (urls) [Project]

 HTML Forms generation and validation 2008.04.30 (Default)
Section: Unix

 

Added: Mon, May 29th 2000 04:30 UTC (8 years, 2 months ago) Updated: Tue, Aug 19th 2008 15:05 UTC (2 days ago)


Screenshot About:
HTML Forms generation and validation is a PHP class that generates HTML forms supporting many built-in validation types on server and client sides. It prevents security attacks by discarding spoofed values, has multiple submit protection, outputs HTML for fields displayed as fully accessible or in read-only mode, and has field value filtering and reformatting. It can be extended with custom control plug-ins. AJAX based form submission, upload monitor progress bar, auto-complete text input, automatic layout renderer, calendar date, CAPTCHA, Google Maps world location selection, linked select, and animation effects plug-ins are available.

Release focus: Major feature enhancements

Changes:
The paged layout plug-in was enhanced to automatically adjust the container size to fit all pages. Now it also supports displaying caption texts at the top of each page. The vertical layout plug-in was also enhanced to support displaying multiple groups of inputs in side by side columns. The date input plug-in has a new option to let the user set a value different from the default only after clicking on a check box.

Author:
Manuel Lemos [contact developer]

Rating:
8.23/10.00 (24 votes)

Homepage:
http://www.phpclasses.org/formsgeneration
Mailing list archive:
http://groups.yahoo.com/group/forms-dev/
Mirror site:
http://en.static.phpclasses.org/browse/package/1.html
Demo site:
http://www.meta-language.net/forms-examples.html

Trove categories: [change]
[Development Status]  6 - Mature
[Environment]  Web Environment
[Intended Audience]  Developers
[License]  OSI Approved :: BSD License (original), OSI Approved :: BSD License (revised)
[Operating System]  OS Independent
[Programming Language]  PHP
[Topic]  Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries, Software Development :: Libraries :: PHP Classes

Dependencies: [change]
Metabase (optional)
[download links]

 
Project admins: [change]
» Manuel Lemos (Owner)

» Rating: 8.23/10.00 (Rank 351)
» Vitality: 31.65% (Rank 12)
» Popularity: 10.29% (Rank 215)

project statsdownload stats
(click to enlarge graphs)
   Record hits: 135,820
   URL hits: 60,394
   Subscribers: 204

Projects depending on this project:
Metastorage
Ezmlm Mailing List Manager Class
Database access class
Multipage forms generation and validation class


Other projects from the same categories:
cgi-wrap.c
PDML
IAM_XLS
ctk-cgi-chkurl
JVanish

Users who subscribed to this project also subscribed to:
1VideoConference
OTRS
mp3fs transcoding FUSE filesystem
Document clustering
Python to C Module Generator


Add comment · Rate this project · Subscribe to new releases · Ignore this project · Email this project to a friend · Project record in XML

 Branches

Branch Version Last release License URLs
Default 2008.08.18 19-Aug-2008 BSD License (original) Homepage

 Releases

Version Focus Date
2008.08.18 Major bugfixes 19-Aug-2008 15:05
2008.06.03 Major feature enhancements 03-Jun-2008 12:55
2008.04.30 Major feature enhancements 05-May-2008 13:31
2008.04.06 Major feature enhancements 07-Apr-2008 12:30
2008.03.24 Major feature enhancements 25-Mar-2008 09:55
2008.03.13 Major feature enhancements 17-Mar-2008 13:15
2008.03.03 Major feature enhancements 04-Mar-2008 09:02
2008.02.27 Major feature enhancements 27-Feb-2008 12:42
2008.02.15 Major feature enhancements 18-Feb-2008 13:25
2008.02.05 Major feature enhancements 07-Feb-2008 14:44

 Comments

[»] Project hosting
by rainer - Jul 19th 2006 04:14:31

This project, like all others from this author, is hosted at phpclasses.org, an absolutely obnoxious site which apparently only exists to throw as much advertising as possible towards its users. Apart from frequent pop-up windows and redirects, they require subscription for downloading, openly announce that they will bombard every subscriber with spam ('newsletters', as they call it), and make an extra effort to prevent subscriptions with a disposable address from spamgourmet.com. Thankfully, they don't know all domains for spamgourmet.

[reply] [top]


    [»] Re: Project hosting
    by Manuel Lemos - Jul 19th 2006 13:31:13

    I am afraid there are several misunderstandings here.

    As the author of these classes, I can tell you that the service provided by the site is wonderful. It keeps track of all users that download my classes. When I release an update, an automatic newsletter is sent to my class users to let them know about the changes, so they can be kept up to data and always use the latest version with the newest improvements and bug fixes.

    If you do not want to receive the site newsletters, that is OK. You can choose which newsletters you want to receive or not in the user options page, or by sending an unsubscribe request to an address mentioned at the bottom of each message.

    Furthermore, when I release new classes, the site sends a newsletter telling all users about it.

    This is great because it provides extraordinary exposure to the work of any developers that shares his PHP work in the site.

    I don't know many other sites that help Open Source developers keeping so many of their users so closely up to date.

    I don't know either if you develop and share your work as Open Source. I am sure if you would develop Open Source projects, you would appreciate the service provided by the site.

    Now, as developer of the site, I must tell you that if you do not like advertising, I do not like it better.

    Unfortunately it is a necessary burden to expose the users to the site advertising. If it were not for that, the site would have been closed a long time ago, like with all those .com sites that died because their owners missed the fact that it is necessary to generate enough revenue to pay for the site hosting, bandwidth and all the people involved in keeping a busy like this up and running.

    Fortunately, soon there will be an alternative to all those that do not want to put up with the advertising. There is a package of premium services being developed to be offered exclusively to subscribers that want to adhere for a small monthly fee (say USD $5 or so).

    Among other interesting new services have been announced in the site blog, premium subscribers will be able access the site without any advertising, have a better site search, improved AJAX based user interface, etc..

    These services have been developed very slowly because the current site revenue is not enough to pay for additional staff.

    Meanwhile there are already a few beta testers evaluating the new services. If you are interested, you may submit a request to become a beta tester, as it has been announce here.

    It is impossible to please everybody, but at least I try to please the users that really care about the site and want to benefit from thousands of classes shared by hundreds of developers.

    I hope you understand.

    [reply] [top]


      [»] Re: Project hosting
      by rainer - Jul 20th 2006 08:49:14


      > As the author of these classes, I can
      > tell you that the service provided by
      > the site is wonderful.

      (snip)


      > I am
      > sure if you would develop Open Source
      > projects, you would appreciate the
      > service provided by the site.

      I am developing open source projects, and I certainly wouldn't consider hosting them on this site, for the following reasons:

      1. It is almost impossible to navigate the site. Almost every link either pops up some ad, or redirects to a full-page ad that redirects to the target page after some timeout. This is not the kind of site where I would like to dwell for some time, looking around for goodies - rather it is exactly the type of site that I wish to visit for the shortest amount of time possible, and wish to leave as soon as possible. Let alone that the ads are not even on topic.

      I fully admit that there is a need for generating revenue by ads - google does it, freshmeat does it, almost everyone else does it, too - but there are obnoxious ways of advertising, and friendly/bearable ones. phpclasses.org is one of the worst I've ever come to see. An important part of good advertisement is the art of attracting users, instead of alienating them.

      2. You say that one can opt out of the 'newsletters'. Then why does the site try to prevent signing up with a spamgourmet mail address? If I can opt out anyway, the site shouldn't care. The only possible reason for caring is the desire to collect valid email addresses (for spam?).

      3. If I want to be informed about updates to some software, I can always subscribe to it on freshmeat. This is much nicer (because I can opt-in, rather than having to opt-out of something I didn't ever want in the first place).

      4. As a developer, I don't want to expose my users to a flood of junk ads, and I also don't want to force emails down their throat. I'd rather prefer if they have a pleasurable overall experience.

      [reply] [top]


        [»] Re: Project hosting
        by Manuel Lemos - Jul 20th 2006 20:53:03


        > % I am

        > % sure if you would develop Open Source

        > % projects, you would appreciate the

        > % service provided by the site.

        >

        > I am developing open source projects,

        > and I certainly wouldn't

        > consider hosting them on this site, for

        > the following reasons:


        Whether or not you submit any projects of yours to the site, it is only your decision. If you choose to exclude yourself from benefiting of the exposure that the site provides to authors, it is solely your problem. Nobody will be upset.



        > 1. It is almost impossible to navigate

        > the site. Almost every link either pops

        > up some ad, or redirects to a full-page

        > ad that redirects to the target page

        > after some timeout. This is not the kind

        > of site where I would like to dwell for

        > some time, looking around for goodies -

        > rather it is exactly the type of site

        > that I wish to visit for the shortest

        > amount of time possible, and wish to

        > leave as soon as possible. Let alone

        > that the ads are not even on topic.

        >

        > I fully admit that there is a need for

        > generating revenue by ads - google does

        > it, freshmeat does it, almost everyone

        > else does it, too - but there are

        > obnoxious ways of advertising, and

        > friendly/bearable ones. phpclasses.org

        > is one of the worst I've ever come to

        > see. An important part of good

        > advertisement is the art of attracting

        > users, instead of alienating them.

        >


        Trust me, the site puts advertising recommended by ad agencies like Google AdSense, Fastclick, Tribafusion, etc.. It puts all the ads that you see because it needs the revenue to survive. It is certainly not to annoy the users, although it is impossible to not annoy some.

        It is like free television channels. They are free, but you need to put up with whatever advertising they present. You can subscribe to cable television to get less advertising, but you still will get some channels with advertising.

        As I mentioned, the site will provide ad-free paid options similar to buying a cable television subscription. Users that do not like advertising will have that option. That is a good alternative to keep the site viable.

        It is pointless to complain that the advertising is not on-topic or you do not like the way it is presented. I do not have the privilege to discard most the advertising because the site would not survive without it.

        If you have difficulty to understand this, maybe when you have a site like this to maintain, you will be able to realize the things as they are, not the way you wished.


        >

        > 2. You say that one can opt out of the

        > 'newsletters'. Then why does the site

        > try to prevent signing up with a

        > spamgourmet mail address? If I can opt

        > out anyway, the site shouldn't care. The

        > only possible reason for caring is the

        > desire to collect valid email addresses

        > (for spam?).


        It is nothing like that. Accepting subscriptions of users with disposable addresses causes several problems.

        Unfortunately it is too easy to create new accounts with disposable addresses. That helps cheating authors to create new accounts to overrate their packages and gain elicit exposure. In some cases they could gain undeserved prizes like in the PHP Programming Innovation Award. This is totally unfair to authors that really deserve to win.

        Another problem is that most disposable address systems accept the newsletter messages forever, even though no user will receive and benefit from them. This makes the site waste bandwidth for nothing.

        The site is on budget with hosting costs. To not raise prices the hosting company has put a bandwidth cap. This means that the transfer rate is limited.

        When the site is serving too many pages or too many newsletters at the same time, connections are put on hold and the Web site users will suffer from site slow down.

        Therefore, the site had to put on an effort to limit the bandwidth used by sending the newsletters. Not accepting subscriptions of users with disposable addresses was one of the measures.


        >

        > 3.

        > If I want to be informed about updates

        > to some software, I can always subscribe

        > to it on freshmeat. This is much nicer

        > (because I can opt-in, rather than

        > having to opt-out of something I didn't

        > ever want in the first place).

        >


        Nonsense, most PHP users and authors do not even know Freshmeat.



        >

        > 4.

        > As a developer, I don't want to freshmeat
        my users to a flood of junk ads, and I

        > also don't want to force emails down

        > their throat. I'd rather prefer if they

        > have a pleasurable overall experience.

        >


        As I said above, that is totally your problem. The PHPClasses site provides a tremendous exposure to the authors work. The site has over 370,000 subscribers and is growing at a rate of about 10,000 new subscribers a month. Of these near 150,000 receive new class alerts newsletters at least once a week.

        There are also the valuable prizes to the winning authors of the innovation award can gain.

        If you do not care about the benefits provided by the site, that is ok. As I also mentioned it is impossible to please everybody. The site is focused in pleasing those that care, while keeping itself financially viable. Any reasonable human being can understand this.

        [reply] [top]


          [»] Re: Project hosting
          by pilo - Aug 9th 2006 17:05:29


          > Nonsense, most PHP users and authors do not even know Freshmeat.

          This begs the question: why do you keep advertising your stuff on the oh-so-unknown and inferior freshmeat site then?


          > [...] Any reasonable human being can understand this.

          While some human beings never seem to comprehend whose unreasonable stubbornness actually triggered the 200th(?) flamefest on this topic.

          [reply] [top]


            [»] Re: Project hosting
            by Manuel Lemos - Aug 9th 2006 21:47:59


            > This begs the question: why do you keep

            > advertising your stuff on the

            > oh-so-unknown and inferior freshmeat

            > site then?


            Please don't put words in my mouth. I never said or meant that Freshmeat is an inferior site. I was not comparing it to anything else. What I meant is that nobody knows all sites, not even a great part of those that exist. So, it is only natural that PHP classes site users and authors do not know Freshmeat.

            Furthermore, the purpose and scope of the sites is different. In the PHPClasses site you can browse and download the PHP packages published their. In Freshmeat you see only announcements about packages that are not available here, but include other languages besides PHP, as well PHP packages published in other sites.

            Announcing packages in Freshmeat can always help authors letting others know their work, regardless whether they published in the PHPClasses site or not.


            > % [...] Any reasonable human being can

            > understand this.

            >

            > While some human beings never seem to

            > comprehend whose unreasonable

            > stubbornness actually triggered the

            > 200th(?) flamefest on this topic.


            While people are able to stay reasonable and put pertinent questions without intention to cause tumult and without departing to personal insult, I can try to be patient and explain why certain things are not the way those people think it should be. If your intention is just to throw more flames just because you do not agree with the way the site operates, sorry I cannot justify any further time to follow-up.

            [reply] [top]


[»] install docs?
by k1mgy - Jul 16th 2006 10:07:33

Maybe I'm blind, but I cannot seem to find any readme or setup docs for this excellent set of classes.

I've installed metabase nicely and it works great, and would like to give this one a go.

[reply] [top]


    [»] Re: install docs?
    by Manuel Lemos - Jul 16th 2006 12:10:14

    The reference manual is the first file in the package files listing. You may also want to take a look at the example scripts . Those are commented and demonstrate practically all the class features. For further support questions, I recommend that you use the package support forum.

    [reply] [top]


[»] A great developer-friendly class
by powerobject - Jan 11th 2006 20:07:06

Oops! My earlier message got garbled and lost the <br>'s.

Hi Manuel,

Simply a 'great' class - very thorough and exhaustive to the detail although one may not use each and every function from its API but who knows? When you need a feature and you know it is there, it feels good and that's what makes a software a success. Excellent and consistent coding style. A developer-friendly class in that it does client-side as well as server-side validations with a single configuration of the inputs whereas other classes such as SmartyValidate, FormCat, etc. do either client-side or server-side validations but not both. And to know it is over 5 years old means it is almost bullet-proof. Includes most features that developers look forward to using in their day-to-day coding which shows the author's experience-level.

Here are a few suggestions:

Although descriptive, the title of the class is long and too generic: Forms generation and validation. How about branding it with a short name (no offense intended as the class itself rocks!)? Such as 'PHORM' or 'DynaForm' or 'DynaGen' or 'DynaValid' or 'PFGV' or 'FGV' or something suitable (however, I'm not aware of existing trademarks). Branding makes a product more popular and a domestic name.

Considering its 3500+ lines of code size, how does the class perform? Is this class being used on any large/high-traffic/high-availability websites? If not, is it possible to dish out a 'Lite' version skimping out some fat? There are so many features in this class such as 'accessibility_tab_index', etc. that every site may not use. On the other hand, support for Smarty is refreshing and very much desirable to be retained.

Is there a way to implement features to configure changing the colors of the field-labels and flashing a dialog with a consolidated message for 'all' the errors (with an optional Beep) on the form? It may be possible with some plugin/custom functions but would be ideal to implement them within the class. Here is an example:
http://www.softcomplex.com/products/tigra_form_validator/registration_form_validation.html

Date fields (dropdowns):

Prefer international format: [Year] [Month] [Day] (or is there a way to shuffle them depending on the locale?)
With the above arrangement, the class can effectively and dynamically filter the number of days in a month based on the Year and Month selection. For instance, Feb (28), Leap Year (29), Sep (30) and Dec (31). This helps in reducing lame data-entry errors as the code is self-correcting and self-validating.

Date Range: In case of two date fields for a range of dates such as Date of Arrival and Date of Departure (one >= the other), it would be thrilling to have the second date field automatically filtering out the invalid Years/Months/Days based on the Year/Month/Day selection in the first date. For instance:

A person arrives on 2000/3/15 and departs on 2000/3/25. When the user chooses the first date field as 2000/3/15, the Years in the second date field should show only years that are >= 2000. Once the user selects 2000 in the second date field, the Months dropdown should show only values >= 3; once the user selects 3 for the month in the second date field, the Days dropdown should show only days >= 15 as it doesn't make sense for someone to arrive after he/she departed (well, technically). Users would get a kick out of such interface for it being intuitive, intelligent and user-friendly which they experienced only in older client/server apps. This feature would be in addition to the equality (password) and difference (reminder) features. Is this something possible with Connect()/linked-select?

Reserved Words: Some vars (error, form, etc) seem to be conflicting with the reserved words of other interfaces such as Flash, Flex, etc. should the developer want to pass values to those interfaces instead of HTML.
ResubmitConfirmMessage: Incorporate a feature to disable the Submit button 'OnSubmit' as default.

Email Validation: Are the validations/regex in this class adequate? See:

http://www.ilovejackdaniels.com/php/email-address-validation
http://www.ilovejackdaniels.com/php/email-address-validation/comments

Thanks much and keep up the good work...

---
PowerObject!

[reply] [top]


[»] A great developer-friendly class
by powerobject - Jan 11th 2006 19:45:37

Hi Manuel, Simply a 'great' class - very thorough and exhaustive to the detail although one may not use each and every function from its API but who knows? When you need a feature and you know it is there, it feels good and that's what makes a software a success. Excellent and consistent coding style. A developer-friendly class in that it does client-side as well as server-side validations with a single configuration of the inputs whereas other classes such as SmartyValidate, FormCat, etc. do either client-side or server-side validations but not both. And to know it is over 5 years old means it is almost bullet-proof. Includes most features that developers look forward to using in their day-to-day coding which shows the author's experience-level. Here are a few suggestions: Although descriptive, the title of the class is long and too generic: Forms generation and validation. How about branding it with a short name? Such as 'PHORM' or 'DynaForm' or 'DynaGen' or 'DynaValid' or 'PFGV' or 'FGV' or something suitable (however, I'm not aware of existing trademarks). Branding makes a product more popular and a domestic name. Considering its size, how does it perform? Is this class being used on any large/high-traffic/high-availability websites? If not, is it possible to dish out a 'Lite' version skimping out some fat? There are so many features in this class such as 'accessibility_tab_index', etc. that every site may not use. On the other hand, support for Smarty is refreshing and very much desirable to be retained. Is there a way to implement features to configure changing the colors of the field-labels and flashing a dialog with a consolidated message for 'all' the errors (with an optional Beep) on the form? It may be possible with some plugin/custom functions but would be ideal to implement them within the class. Here is an example: http://www.softcomplex.com/products/tigra_form_validator/registration_form_validation.html Date fields (dropdowns): Prefer international format: [Year] [Month] [Day] (or is there a way to shuffle them depending on the locale?) With the above arrangement, the class can effectively and dynamically filter the number of days in a month based on the Year and Month selection. For instance, Feb (28), Leap Year (29), Sep (30) and Dec (31). This helps in reducing lame data-entry errors as the code is self-correcting and self-validating. Date Range: In case of two date fields for a range of dates such as Date of Arrival and Date of Departure (one >= the other), it would be thrilling to have the second date field automatically filtering out the invalid Years/Months/Days based on the Year/Month/Day selection in the first date. For instance: A person arrives on 2000/3/15 and departs on 2000/3/25. When the user chooses the first date field as 2000/3/15, the Years in the second date field should show only years that are >= 2000. Once the user selects 2000 in the second date field, the Months dropdown should show only values >= 3; once the user selects 3 for the month in the second date field, the Days dropdown should show only days >= 15 as it doesn't make sense for someone to arrive after he/she departed (well, technically). Users would get a kick out of such interface for it being intuitive, intelligent and user-friendly which they experienced only in older client/server apps. This feature would be in addition to the equality (password) and difference (reminder) features. Is this something possible with Connect()/linked-select? Reserved Words: Some vars (error, form, etc) seem to be conflicting with the reserved words of other interfaces such as Flash, Flex, etc. should the developer want to pass values to those interfaces instead of HTML. ResubmitConfirmMessage: Incorporate a feature to disable the Submit button 'OnSubmit' as default. Email Validation: Are the validations/regex in this class adequate? See: http://www.ilovejackdaniels.com/php/email-address-validation http://www.ilovejackdaniels.com/php/email-address-validation/comments Thanks much and keep up the good work... --- PowerObject!

[reply] [top]


[»] form example with GetInputEventURL
by FlavioR - May 20th 2005 06:14:57

Manuel Lemos
Can you post or send me one example in form.php with the new functions "GetInputEventURL" and "HandleEvent"?
Thanks

[reply] [top]


    [»] Re: form example with GetInputEventURL
    by Manuel Lemos - May 20th 2005 11:06:06


    > Manuel Lemos

    > Can you post or send me one example in

    > form.php with the new functions

    > "GetInputEventURL" and

    > "HandleEvent"?

    > Thanks


    That is meant mostly for custom input plug-in classes. Please take a look at the CAPTCHA plug-in class that comes with the class package.

    [reply] [top]


[»] Select Options
by RossC0 - Oct 26th 2004 02:21:06

Hi,

Great class.
Any plans to add optgroups into select options ?

[reply] [top]


    [»] Re: Select Options
    by Manuel Lemos - Oct 26th 2004 10:27:05


    > Great class.

    > Any plans to add optgroups into select

    > options ?


    I could implement that but I do not have a good idea of how it could be implemented in a straight forward manner.

    I could associate an optgroup to an option value, but I am not sure how it could define the menu hierarchy.

    Do you have any suggestion?

    [reply] [top]


      [»] Re: Select Options
      by RossC0 - Nov 2nd 2004 03:14:05


      >

      > I could implement that but I do not have

      > a good idea of how it could be

      > implemented in a straight forward

      > manner.

      >

      > I could associate an optgroup to an

      > option value, but I am not sure how it

      > could define the menu hierarchy.

      >

      > Do you have any suggestion?


      Yes I agree it is a little complicated to ensure the logic is correct as optiongroups can't be nested and you rely heavily on the user initiating the class correctly.

      One approach would be to create optiongroup array and use this to build the select options instead. So you wouldn't have an OPTIONS index for the AddInput function if the user chose to use optiongroups. (This should make it easier to include into the existing code and help clean up the logic of the optiongroups).

      Each item in the array would contain an array of select options and if it is an option group it will contain a label also. If an array doesn't have a label then it is not inside an option group and can be directly outputted as an option.

      sudo code example.

      $optionGroups = array();
      $optionGroup[] = array("LABEL" => 'groupOne', "OPTIONS" => array(options););
      $optionGroup[] = array("LABEL" => 'groupTwo', "OPTIONS" => array(options););
      $optionGroup[] = array("OPTIONS" => array(options););

      // Then when setting up the form input:
      $myform->AddInput(array(
      "TYPE"=>"select",
      "NAME"=>"selectOptions",
      "ID"=>"selectOptions1",
      "SELECTED"=>$mySelectedOptions,
      "SIZE"=>3,
      "OPTGROUP" => $optionGroups;
      ));


      Then when parsing the select option element, you would check if it has a label, if so add optgroup tags and label the optgroup, loop the options and then close the optgroup. If there is no label then the loop the options and output.

      Does that sound feasible / logical ?

      [reply] [top]


        [»] Re: Select Options
        by Manuel Lemos - Nov 2nd 2004 12:29:33


        > One approach would be to create

        > optiongroup array and use this to build

        > the select options instead. So you

        > wouldn't have an OPTIONS index for the

        > AddInput function if the user chose to

        > use optiongroups. (This should make it

        > easier to include into the existing code

        > and help clean up the logic of the

        > optiongroups).

        >

        > Each item in the array would contain an

        > array of select options and if it is an

        > option group it will contain a label

        > also. If an array doesn't have a label

        > then it is not inside an option group

        > and can be directly outputted as an

        > option.


        I think this is a bit more complicated then I wanted.

        The way I see the OPTIONS do not have their definitions changed when they are grouped. So I think it would be better to let OPTIONS definition remain as it is.

        What can be added is the definition of the groups, associating a label to the values of the respective options, more or less like this:

        "OPTGROUPS"=>array(
        "group1"=>array(
        "value1",
        "value2"
        ),
        "group2"=>array(
        "value3",
        "value4"
        )
        );

        What do you think?

        [reply] [top]


          [»] Re: Select Options
          by RossC0 - Nov 3rd 2004 01:47:10


          > I think this is a bit more complicated

          > then I wanted.

          >

          > The way I see the OPTIONS do not have

          > their definitions changed when they are

          > grouped. So I think it would be better

          > to let OPTIONS definition remain as it

          > is.

          >

          > What can be added is the definition of

          > the groups, associating a label to the

          > values of the respective options, more

          > or less like this:

          >

          > "OPTGROUPS"=>array(

          > "group1"=>array(

          > "value1",

          > "value2"

          > ),

          > "group2"=>array(

          > "value3",

          > "value4"

          > )

          > );

          >

          > What do you think?


          That definately, would be the easiest option - the only problem I can see is catching any errors if a user tries to add groups that aren't chronological, or tries to nest option groups.

          But, it would fit in nicely with the syntax of Select Options in your class and I would happily use that approach.

          Thanks

          Ross

          [reply] [top]


            [»] Re: Select Options
            by Manuel Lemos - Nov 5th 2004 12:10:39


            > That definately, would be the easiest

            > option - the only problem I can see is

            > catching any errors if a user tries to

            > add groups that aren't chronological, or

            > tries to nest option groups.

            >

            > But, it would fit in nicely with the

            > syntax of Select Options in your class

            > and I would happily use that approach.


            Ok, I will try to implement it soon.

            [reply] [top]


              [»] Re: Select Options
              by Zac - Dec 22nd 2005 08:07:38


              > Ok, I will try to implement it soon.


              Does anyone know if this has been implemented? I need
              optgroups for a project I'm working on, so I'd planned to
              write a quick hack to enable them -- however, if this has
              already been implemented properly, I don't want to
              duplicate someone else's work.

              Thanks!

              [reply] [top]


                [»] Re: Select Options
                by Manuel Lemos - Dec 23rd 2005 19:16:23


                > Does anyone know if this has been

                > implemented? I need

                > optgroups for a project I'm working on,

                > so I'd planned to

                > write a quick hack to enable them --

                > however, if this has

                > already been implemented properly, I

                > don't want to

                > duplicate someone else's work.


                Coincidently, I was planning to implement it in January as part of a major overhaul to the select input support. But feel free to develop whatever you need for now.

                [reply] [top]


[»] some suggestions
by giuseppe minutillo - Oct 15th 2004 04:26:05

Hi,
I just started using this class and I thik that is very useful and flexible.

I have some suggestions:

first:
can add support of ID, STYLE and CLASS attributes in the LABEL element?
it is very useful when the form are styled with a CSS.

second:
can add support of the ID attribute in the FORM element?
the XHTLM Strict not admit the NAME attribute in the FORM tag.

how do you think about?

[reply] [top]


    [»] Re: some suggestions
    by Manuel Lemos - Oct 21st 2004 11:32:26


    > first:

    > can add support of ID, STYLE and CLASS

    > attributes in the LABEL element?

    > it is very useful when the form are

    > styled with a CSS.


    Ok, I will add that for the next release, probably next week.


    > second:

    > can add support of the ID attribute in

    > the FORM element?

    > the XHTLM Strict not admit the NAME

    > attribute in the FORM tag.


    I can add support for that too, but you can use the class ExtraAttributes variable to specify values that do not have built-in support.

    [reply] [top]


[»] Does This Class Work with Register_Globals = Off?
by Francis Chang - Oct 12th 2004 01:54:15

Hi,

I'm running Php 5.0 with Register_Globals = Off. I seem to have a problem when calling the $form->WasSubmitted function. The function keeps returning a null string even though the form was submitted previously. It seems that the IsSetValue method makes uses of globals.

Is this class certified for Php 5.0 with register_globals off? If not, any suggestions on how we might be able to make it work?

Thanks in advance for your input.

Francis

[reply] [top]


    [»] Re: Does This Class Work with Register_Globals = Off?
    by Manuel Lemos - Oct 12th 2004 18:02:02


    > I'm running Php 5.0 with

    > Register_Globals = Off. I seem to have

    > a problem when calling the

    > $form->WasSubmitted function. The

    > function keeps returning a null string

    > even though the form was submitted

    > previously. It seems that the

    > IsSetValue method makes uses of globals.

    No, the IsSetValue function also checks the $_POST and $_GET variables, so there is no reason for it not work as intended.

    I suspect that you are not specifying a specific input name for the WasSubmitted function to check and that makes it traverse all the form fields to determine which submit button was used.

    In this case, it only works if the submit inputs in your form set the NAME attribute. Otherwise the class does not have a reliable way to determine whether the form was submitted.

    If this is your problem, just define the NAME attribute of your form submit inputs.

    [reply] [top]


[»] Validate All Fields Regardless of Erros?
by Francis Chang - Oct 11th 2004 11:32:56

Hi,

First of all, great class!

I have to admit that I just started using this class and haven't spent a lot of time with it. I have a general question to which I couldn't find the answer in the documentation.

It seems that the class will stop validating on the server side once the first error is found. Is it possible to have the server to continue validating all the fields and return all the possible errors? This is obviously a usability issue. If this is not possible, how difficult would it be to extend the class to do so?

Thanks.

[reply] [top]


    [»] Re: Validate All Fields Regardless of Erros?
    by Manuel Lemos - Oct 11th 2004 11:42:38


    > It seems that the class will stop

    > validating on the server side once the

    > first error is found. Is it possible to

    > have the server to continue validating

    > all the fields and return all the

    > possible errors? This is obviously a

    > usability issue. If this is not

    > possible, how difficult would it be to

    > extend the class to do so?


    No, the class validates all fields when you call Validate. It returns the error message associated to the validation rules that fails on the first invalid field, but the verify array enumerates all fields that are invalid.

    [reply] [top]


      [»] Re: Validate All Fields Regardless of Erros?
      by Francis Chang - Oct 11th 2004 23:16:40

      Thanks Manual for your reply. To confirm my understanding,

      The Verify array will enumerate all the fields that failed validation and the error message that is returned will contain all the error messages (if the field has multiple validation rules with multiple failures) that are associated with the first field that failed validation? Is that correct?

      Francis




      >

      > % It seems that the class will stop

      > % validating on the server side once

      > the

      > % first error is found. Is it possible

      > to

      > % have the server to continue

      > validating

      > % all the fields and return all the

      > % possible errors? This is obviously a

      > % usability issue. If this is not

      > % possible, how difficult would it be

      > to

      > % extend the class to do so?

      >

      >

      >

      > No, the class validates all fields when

      > you call Validate. It returns the error

      > message associated to the validation

      > rules that fails on the first invalid

      > field, but the verify array enumerates

      > all fields that are invalid.

      >

      [reply] [top]


[»] Result code
by Melvin - Sep 29th 2004 23:30:11

The resulting code can get really messy when working with really big forms, just make sure to comment what you are doing.

It has very good features I really liked.

[reply] [top]


[»] Hidden Fields not showing up
by Tom - Aug 1st 2004 12:36:17

I love the class, it's really saving me time. For some reason I can't seem to get any hidden input fields to show up when I check the $_POST array. Is there something that needs to be set to make them be processed?

[reply] [top]


    [»] Re: Hidden Fields not showing up
    by Tom - Aug 1st 2004 12:54:36


    > I love the class, it's really saving me

    > time. For some reason I can't seem to

    > get any hidden input fields to show up

    > when I check the $_POST array. Is there

    > something that needs to be set to make

    > them be processed?

    Never mind.
    I found where I needed to put the AddInputPart in the template.

    [reply] [top]


[»] Server-Side Validation
by RossC0 - Jul 21st 2004 08:58:27

Hi,

First of all an excellent class! I have one question. How do I use the ServerSide Validation, instead of client side?

I flagged the ValidateServerSideOnly on textbox array and I've set the validation reg-ex and messages - however it still produces javascript ?!

Also with ValidateServerSideOnly do I use the set reg-ex to validate the posted variable and then output the error message on the form - if so how?

Kind regards,

Ross

[reply] [top]


    [»] Re: Server-Side Validation
    by Manuel Lemos - Jul 21st 2004 11:52:16


    > First of all an excellent class!


    Thanks! ;-)


    > I have one question. How do I use the

    > ServerSide Validation, instead of client

    > side?

    >

    > I flagged the ValidateServerSideOnly on

    > textbox array and I've set the

    > validation reg-ex and messages - however

    > it still produces javascript ?!


    Couldn't you have an AddFunction() call to set the form initial focus input, or maybe set the ResubmitConfirmMessage class variable to prevent submitting the form more than once?

    These would lead to additional Javascript generation. If you do not have any of these, please send me a minimal example script that exhibits the problem.



    > Also with ValidateServerSideOnly do I

    > use the set reg-ex to validate the

    > posted variable and then output the

    > error message on the form - if so how?


    I am not sure what you are asking. If you want to validate a field with a regular expression just use the ValidateRegularExpression parameter, regardless whether it will validate on the client side too or not.

    Validation on the server side happens when you can the Validate function of the class as you may see in the examples.

    [reply] [top]


      [»] Re: Server-Side Validation
      by RossC0 - Jul 22nd 2004 03:53:50

      Hi thanks for your quick reply, I'm sorry I don't think I was very clear so here is some sample code:

      Heres a copy of my array set up:

      $form->AddInput(array(
      'TYPE'=>'text',
      'NAME'=>'searchString',
      'ID'=>'searchString',
      'MAXLENGTH'=>100,
      'ValidationOnlyOnServerSide' =>'Y',
      'ValidateRegularExpression'=>'^[a-zA-Z0-9_]{1,100}$',
      'ValidateRegularExpressionErrorMessage'=>'Please enter valid search text',
      'LABEL'=>'searchString',
      'VALUE'=>$searchString
      ));

      Ideally, what I want to do is catch any errors after the user has submitted the form. I don't want javascript validation to be performed as I really want more control on how the validation error messages are displayed on page.

      However, I do want to set up the reg-ex and the error message in the array (as it keeps all the html item data together). Is this approach possible with this class ?

      [reply] [top]


        [»] Re: Server-Side Validation
        by Manuel Lemos - Jul 22nd 2004 17:18:29


        > Ideally, what I want to do is catch any

        > errors after the user has submitted the

        > form. I don't want javascript

        > validation to be performed as I really

        > want more control on how the validation

        > error messages are displayed on page.


        Sure. BTW, I am working on a new version that lets you specify a new Javascript function that is called when a fields does not validate on the client side.

        I don't know if that is what you want, but this feature allows you to provide an alternative validation error notice, instead of using the Javascript alert() message box that many people do not like. The new feature will include a new plugin control for displaying messages in a DHTML layer. I am still experimenting to verify the browser compatibility.



        > However, I do want to set up the reg-ex

        > and the error message in the array (as

        > it keeps all the html item data

        > together).

        >

        > Is this approach possible with this

        > class ?


        Sure. The above definition should provide exactly that.

        [reply] [top]


          [»] Re: Server-Side Validation
          by RossC0 - Jul 23rd 2004 04:55:04


          Manuel - thanks for quick responses, unfortunately, it still seems to be creating javascript form validation even though I have flagged server side validation only on?


          > Sure. BTW, I am working on a new version

          > that lets you specify a new Javascript

          > function that is called when a fields

          > does not validate on the client side.

          >

          > I don't know if that is what you want,

          > but this feature allows you to provide

          > an alternative validation error notice,

          > instead of using the Javascript alert()

          > message box that many people do not

          > like. The new feature will include a new

          > plugin control for displaying messages

          > in a DHTML layer. I am still

          > experimenting to verify the browser

          > compatibility.

          >

          Sounds great - one idea rather than using DHTML which has cross browser issues and may be easier to code is (not sure though):

          You could have a function that checks the returned posted variables against any set reg expressions, this then returns the error message notice if it fails, which in turn can be outputted on the page (or template) above the field.

          I think this approach is used in the old oohforms. It may be simpler than the javascript DHTML method and would provide validation for javascript disabled browsers, but on the downside it means that the page would have to be re submitted.

          Also would solve my problem as well ;-)

          [reply] [top]


            [»] Re: Server-Side Validation
            by Manuel Lemos - Jul 23rd 2004 05:27:08


            > Manuel - thanks for quick responses,

            > unfortunately, it still seems to be

            > creating javascript form validation even

            > though I have flagged server side

            > validation only on?


            As I mentioned before, if it stills generates Javascript is due to other reasons. If you can't figure yourself, I need to see your whole form PHP script to tell you why it generates Javascript and what you need to do to avoid it.


            > You could have a function that checks

            > the returned posted variables against

            > any set reg expressions, this then

            > returns the error message notice if it

            > fails, which in turn can be outputted on

            > the page (or template) above the field.


            This class always did server side and client side validation. The client side validation support is
            optional. To perform server side validation, just call the class functions LoadInputValues and Validate. Please read the documentation and the supplied examples to understand better how it works.

            [reply] [top]


              [»] Re: Server-Side Validation
              by RossC0 - Jul 23rd 2004 07:08:03

              Sorry Manuel, I'm being thick - the ValidateServerSideOnly - isn't producing javascript as I said above! Thank you for you responses - it really is an excellent class! Ross

              [reply] [top]


                [»] Re: Server-Side Validation
                by RossC0 - Jul 23rd 2004 08:41:51


                As I made a fuss and was wrong before!! I thought I'd share a class extension that sets the error messages as an array so you can output error messages where desired on the page:

                include_once 'forms.php';

                class formsExtension extends form_class {

                // Modified Validate Function - to return error messages in an array.
                Function Validate(&$verify,$sub_form="")
                {
                for($inputs=array(), $input_number=0, Reset($this->inputs);$input_numberinputs);Next($this->inputs), $input_number++)
                $inputs[]=Key($this->inputs);
                for($invalid_parents=$custom=array(),$error=array(),$input_number=0;$input_numberinputs[$field]["TYPE"],"custom"))
                {
                if(!IsSet($this->inputs[$field]["DiscardInvalidValues"]))
                {
                $input_error=$this->ValidateInput($field, $this->inputs[$field]["VALUE"], $sub_form);
                if(strlen($input_error))
                {
                if(IsSet($this->inputs[$field]["parent"]))
                {
                $parent=$this->inputs[$field]["parent"];
                $invalid_parents[$parent]=$field;
                $invalid_field=$parent;
                }
                else
                {
                $invalid_field=$field;
                }
                $error[$invalid_field] = $input_error;
                $verify[$invalid_field]=$this->inputs[$invalid_field]["SubForm"];
                }
                }
                }
                else
                $custom[]=$field;
                }
                for($input_number=0;$input_numberinputs[$field]["DiscardInvalidValues"]))
                {
                $input_error=$this->inputs[$field]["object"]->ValidateInput($this);
                if(strlen($input_error))
                {
                $error[$invalid_field] = $input_error;
                $verify[$field]=$this->inputs[$field]["SubForm"];
                }
                }
                }
                return($error);
                }

                function getErrorMessage($errorItem)
                {
                if (!$this->error_message[$errorItem])
                {
                return false;
                }
                else
                {
                $htmlOutput = "".$this->error_message[$errorItem].'';
                print $htmlOutput;
                }
                }

                }

                =====================
                In the template it looks like this:
                =====================





                =====================

                So I can output any errors where they are caused.
                I look forward to the DHTML method also!

                Many Thanks Again
                Ross

                [reply] [top]


                  [»] Re: Server-Side Validation
                  by RossC0 - Jul 23rd 2004 08:44:04

                  =====================
                  In the HTML template its outputted like this:
                  ======================

                  $myform->getErrorMessage('searchString');
                  $myform->AddInputPart('searchString');

                  Sorry it cut my php code

                  [reply] [top]


[»] About other form generators
by Ashley - May 4th 2004 00:20:43

Hi
I have been using pear HTML_QuichForm class for quite some time. I am confused about the difference between Forms generation and validation and the HTML_QuichForm class. Could you help me ?

[reply] [top]


    [»] Re: About other form generators
    by Manuel Lemos - May 4th 2004 01:07:22


    > I have been using pear HTML_QuichForm

    > class for quite some time. I am confused

    > about the difference between Forms

    > generation and validation and the

    > HTML_QuichForm class. Could you help me?

    I am not sure what to tell you because naturally I do not use QuickForm myself.

    Anyway, the Forms Generation and Validation class is now 5 years old and so it matured a lot to meet the needs of many developers. Looking to the page of Quickforms it seems it misses many features provided by this class.

    - Load submitted form field values even with register_globals option Off and strip slashes when magic_quotes_gpc option is On.
    - Keyboard navigation support:
    * Attachment of labels with activation keys to each form field.
    * Tab navigation order index.
    - Security attack prevention by optionally discarding invalid values passed in fields that could not be edited by users but may be spoofed by attackers.
    - Option to define a value that, when used in a field, it is accepted without performing any of the validations defined for the field.
    - Ability to stop the user from submiting a form more than once inadvertdly.
    - Sub form validation (validate only smaller set of field depending on the submit button that was used).
    - Composition and generation of the form HTML output with fields displayed as fully accessible or in read-only mode.
    - Generation of Javascript functions (useful to set to the page ONLOAD event):
    * Set the input focus to a field.
    * Select the text of a field.
    * Set the input focus and select the text of a field.
    * Enable and disable input fields
    - Automatic capitalization of the text of a field:
    * Upper case.
    * Lower case.
    * Word initials
    - Replacement of text field expressions to perform adjustments like trimming whitespace or auto-complete values based on rules defined by regular expressions
    - Compose forms with templates using plain HTML files with embedded PHP code or using the Smarty template engine with a supplied pre-filter plugin

    If you want to know about something more specific, just tell me about it.

    [reply] [top]


      [»] Re: About other form generators
      by Hans de Raad - Jun 29th 2005 03:33:48

      Then why don't you just propose this class on PEAR? It's a shame that these projects keep existing without anyone knowing about them (PEAR is a very nice advertisementboard off course)! Please put this up as a proposal on the pear mailinglist (from which im not an active member) and see what the responses are, why not?! Imho too many usefull classes are not being included into PEAR just for reasons like "having my own little project". Don't know if thats the case here but it would be a shame if you'd miss out because someone was just earlier on PEAR (and QuickForm is already there and does a good job) because of it. Off course your project has to confirm to the Coding Guidelines.

      [reply] [top]


        [»] Re: About other form generators
        by Manuel Lemos - Jun 29th 2005 12:12:00


        > Then why don't you just propose this

        > class on PEAR?

        >

        > It's a shame that these projects keep

        > existing without anyone knowing about

        > them (PEAR is a very nice

        > advertisementboard off course)!

        >

        > Please put this up as a proposal on the

        > pear mailinglist (from which im not an

        > active member) and see what the

        > responses are, why not?!

        >

        > Imho too many usefull classes are not

        > being included into PEAR just for

        > reasons like "having my own little

        > project". Don't know if thats the case

        > here but it would be a shame if you'd

        > miss out because someone was just

        > earlier on PEAR (and QuickForm is

        > already there and does a good job)

        > because of it.

        >

        > Off course your project has to confirm

        > to the Coding Guidelines.

        >

        Unfortunately that is not a viable idea. Basically the problem is that some PEAR people do not want what they call "competing packages", so some PEAR authors (the developers of competing packages) do all that can to keep out other packages, even if those are better than what they have.

        The coding guidelines are often used as an excuse to keep other people packages. I use coding guidelines since many years ago, even before PEAR was ever dreamed. The problem is that I use my own coding guidelines, which are well defined and consistent, not the guidelines that a small group of people of PEAR have chosen to be the ones and the only to be accepted.

        It is not realistic to expect anybody that uses the same coding guidelines for many years to change, just to be accepted in PEAR. It is like asking me to stop writing with right hand, that I use for many years, and start using the left hand instead, just because a small group of people decided that is the correct hand to use. It should not matter what was the hand you used to write good things, but PEAR people do not agree.

        I am not the only one that does not agree with PEAR coding guidelines. Many, many authors dislike PEAR guidelines, some are proeminent authors. I recall that once Andrey Zmievsky (Smarty, PHP-GTK, etc..) said that "PEAR coding guidelines make him cry". As a result you do not see packages like Smarty as part of PEAR either.

        Even if we agreed with PEAR guidelines, it would not be viable for many of us, that hardly have time to do what we do, to convert thousands of lines of our packages, just because they do not comply to PEAR guidelines.

        But that is not the only problem about PEAR. For instance, once you submit your packages to PEAR, other people can mess your code with prior consent or agreement. That is disrespectful and hateful. Basically you loose control as if you no longer own the copyright of your code. Open source and loosing copyright is not the same thing. I do not object people using changed versions of my code, but I object people making changes that I did not agree to my projects in my main work repository. It is hard enough to keep up with the complexity of my projects, even more with a bunch of people messing with the code. Too many cooks spoil the broth.

        Other than that, you do not have freedom to use whatever free software license you want to distribute your code. For instance GPL packages are banned in PEAR, and LGPL is discouraged. Personally I always use BSD license, so that would not be a problem for me, but it would be a problem for other authors that do not agree.

        Originally, PEAR was expected to be CPAN for PHP, but AFAIK Perl CPAN does not impose such restrictions.

        This forms class and all or my classes are distributed in the PHP Classes repository. It is a package repository site that exists for more time than PEAR. It is certainly more popular according to Alexa site popularity rankings.

        The PHP Classes site is much more focused in providing satisfaction to the authors that contribute to it. Therefore it has certain important features that PEAR does not have.

        The PHP Classes site has now 250,000 subscribers, about half of those remain active in the site. This means that whenever you release a new class, about 120,000 users, eager to learn about new classes, are notified by e-mail about the new class. This is an extraordinary way for the class authors to get immediate exposure for their work.

        The PHP Classes site keeps track of all the downloads of all classes. When a class is updated, the users that downloaded it are notified by e-mail about the new release, except for those that do not want e-mail notifications. This helps authors to keep their users upto date using the latest versions, so they do not have to waste time providing support to people using outdated versions, just because they were not aware of the updates.

        The download records are accurate. This allows the authors to know how many unique users have downloaded a class. The site can also build top download and top rated charts that are immune to fraud, so every author gets an equal chance for being recognized for the value of the classes that he is sharing.

        There are other things that the PHP Classes site provides that PEAR doesn't. I do not have anything against those that contribute to PEAR, but unfortunately PEAR does not represent a consense among the PHP community, unlike for instance what CPAN represents for the Perl community.

        [reply] [top]


[»] Some questions
by Sunita - Apr 27th 2004 10:40:22

Is MySQL set up on this? Also, does it store the info in a database or emails it to relevant person?

[reply] [top]


    [»] Re: Some questions
    by Manuel Lemos - Apr 27th 2004 12:47:38


    > Is MySQL set up on this? Also, does it

    > store the info in a database or emails

    > it to relevant person?

    This is just a class the validates and outputs HTML forms. You can build more complex components and applications around it.

    For integration with databases, you may want to try this database access class or use this e-mail message composing and sending class to send messages with the information picked from the submitted forms.

    [reply] [top]


[»] select validation?
by Invitro - Feb 9th 2004 09:58:04

how to validate the drop down list - (not in multiple selection) , i can't get that information. Could you give me a sample code?

[reply] [top]


    [»] Re: select validation?
    by Manuel Lemos - Feb 9th 2004 17:19:59


    > how to validate the drop down list -
    > (not in multiple selection) , i can't
    > get that information. Could you give me
    > a sample code?


    The class always validate the select inputs to verify that the selected values is one of the options list. So, if some hacker submits a form with invalid selected option, the class Validate function detects that. The input ErrorMessage definition argument specifies the error message that is returned.

    [reply] [top]


      [»] Re: select validation?
      by Invitro - Feb 9th 2004 19:12:25


      >
      > % how to validate the drop down list -
      > % (not in multiple selection) , i can't
      > % get that information. Could you give
      > me
      > % a sample code?
      >
      >
      >
      > The class always validate the select
      > inputs to verify that the selected
      > values is one of the options list. So,
      > if some hacker submits a form with
      > invalid selected option, the class
      > Validate function detects that. The
      > input ErrorMessage definition argument
      > specifies the error message that is
      > returned.

      Sorry, but how to validate if I want user to select only one option in a drop down list (they have to select only one option) and the drop down attribute IS NOT 'MULTIPLE => 1'. I've been trying to use ValidateAsNotEmpty but it doesn't work.

      [reply] [top]


        [»] Re: select validation?
        by Manuel Lemos - Feb 9th 2004 19:29:42


        > Sorry, but how to validate if I want
        > user to select only one option in a drop
        > down list (they have to select only one
        > option) and the drop down attribute IS
        > NOT 'MULTIPLE => 1'. I've been trying to
        > use ValidateAsNotEmpty but it doesn't
        > work.
        >

        As I said, you do not have to do anything because the class Validate function always validates normal select input to verify that the selected value is one of the options values.

        [reply] [top]


          [»] Re: select validation?
          by Invitro - Feb 10th 2004 00:59:22


          >
          > % Sorry, but how to validate if I want
          > % user to select only one option in a
          > drop
          > % down list (they have to select only
          > one
          > % option) and the drop down attribute
          > IS
          > % NOT 'MULTIPLE => 1'. I've been trying
          > to
          > % use ValidateAsNotEmpty but it doesn't
          > % work.
          > %
          >
          >
          > As I said, you do not have to do
          > anything because the class Validate
          > function always validates normal select
          > input to verify that the selected value
          > is one of the options values.

          ok thank you very much :)

          [reply] [top]


            [»] Re: select validation?
            by Invitro - Feb 11th 2004 10:51:08

            Sorry, it seems the validate for the select it doesn't work. Btw I have this configuration

            $form->addInput(array(
            "TYPE" => "select",
            "NAME" => "reminder",
            "ID" => "reminder",
            "LABEL" =>"Reminder"
            "VALUE" =>0,
            "ValidateErrorMessage" =>"test"
            "OPTIONS" => array("a", "b")
            ));

            and then I set the drop down list with javascript to have undefined options so the user it must select the correct value, like this:

            <script language="JavaScript" defer="defer">

            var _F = document.form[0];

            // unset selected value form class
            _F.reminder.options[0].selected = false;

            // create new selected value with undefined value
            _F.reminder.options[_F.reminder.options.length] = new Option( "[Select a Reminder]", "ud", true, true );

            </script>

            and when I'm submitting the form, it seems the class not validate anything...do you have any suggestions for this?

            [reply] [top]


              [»] Re: select validation?
              by Manuel Lemos - Feb 11th 2004 12:59:23


              > Sorry, it seems the validate for the
              > select it doesn't work. Btw I have this
              > configuration
              >
              >
              > $form->addInput(array(
              > "TYPE" => "select",
              > "NAME" => "reminder",
              > "ID" => "reminder",
              > "LABEL" =>"Reminder"
              > "VALUE" =>0,
              > "ValidateErrorMessage" =>"test"
              > "OPTIONS" => array("a", "b")
              > ));

              This is not accepted. You need to specify an associative array for the options. Also, you cannot have a simple select input without selecting an option. AddInput function would not add the input and return an error.

              What you want to do can be achived like this:

              $form->addInput(array(
              "TYPE" => "select",
              "NAME" => "reminder",
              "ID" => "reminder",
              "LABEL" =>"Reminder"
              "VALUE" =>"",
              "ValidateAsNotEmpty" =>1,
              "ValidateErrorMessage" =>"You have not selected a valid reminder option.",
              "OPTIONS" => array(
              ""=>"Please select a reminder",
              "0"=>"a",
              "1"=>"b"
              )
              ));

              [reply] [top]


                [»] Re: select validation?
                by Invitro - Feb 11th 2004 22:29:05


                >
                > % Sorry, it seems the validate for the
                > % select it doesn't work. Btw I have
                > this
                > % configuration
                > %
                > %
                > % $form->addInput(array(
                > % "TYPE" => "select",
                > % "NAME" => "reminder",
                > % "ID" => "reminder",
                > % "LABEL" =>"Reminder"
                > % "VALUE" =>0,
                > % "ValidateErrorMessage" =>"test"
                > % "OPTIONS" => array("a", "b")
                > % ));
                >
                >
                > This is not accepted. You need to
                > specify an associative array for the
                > options. Also, you cannot have a simple
                > select input without selecting an
                > option. AddInput function would not add
                > the input and return an error.
                >
                > What you want to do can be achived like
                > this:
                >
                > $form->addInput(array(
                > "TYPE" => "select",
                > "NAME" => "reminder",
                > "ID" => "reminder",
                > "LABEL" =>"Reminder"
                > "VALUE" =>"",
                > "ValidateAsNotEmpty" =>1,
                > "ValidateErrorMessage" =>"You have not
                > selected a valid reminder option.",
                > "OPTIONS" => array(
                > ""=>"Please select a reminder",
                > "0"=>"a",
                > "1"=>"b"
                > )
                > ));

                Yes, I've change my form like your configuration but the drop down list doesn't show in my html page...maybe I miss something? but I can't found it, do you have any idea? thx in adv

                [reply] [top]


                  [»] Re: select validation?
                  by Manuel Lemos - Feb 12th 2004 07:29:37

                  The AddInput function returns an error when it fails. Just echo that value and you will understand what is wrong.

                  [reply] [top]


                    [»] Re: select validation?
                    by Invitro - Feb 12th 2004 08:46:51

                    Ok, this is the error message

                    reminder: it was not defined a valid input value

                    it seems there's a problem with input value.

                    [reply] [top]


                      [»] Re: select validation?
                      by Invitro - Feb 12th 2004 09:04:26

                      Ok, I think I know where the error is. Sorry for disturbing you.Thanks anyway :)

                      [reply] [top]


    [»] Sorry for posting here, I couldn't find where to post a new comment.
    by nof - Apr 15th 2004 12:51:55

    How would I turn of client side validation completely? I saw nothing in the manual or documentation about this.

    [reply] [top]


      [»] Re: Sorry for posting here, I couldn't find where to post a new comment.
      by Manuel Lemos - Apr 15th 2004 13:08:25

      Currently you can just specify the ValidateOnlyOnClientSide argument per each field that you do not want to validate on the client side.

      [reply] [top]


[»] Is the output of created forms adjustable
by Wookkie - May 30th 2003 02:52:33

Hi i am new to this forms-generation.
It seems to it it is really more powerful than a self written Form-Script.
I use Smarty and also i like the use of css.

So my intention is to format the output of the non-Javacript-validation by css.
After the form is submitted i prefer to have the non validated formfields shown in another css-class.
Another design-thing is that i prefer to otupot the error-messages shown as alt-tags behind a icon-Graphic behind each form-field.
i don't know if this this possible and like to know if this is a difficult thing before i work deeper into this class and, in the end, see that these things probably didn't work.







[reply] [top]


    [»] Re: Is the output of created forms adjustable
    by Manuel Lemos - May 30th 2003 22:58:22


    > I use Smarty and also i like the use of
    > css.
    >
    > So my intention is to format the output
    > of the non-Javacript-validation by css.
    > After the form is submitted i prefer to
    > have the non validated formfields shown
    > in another css-class.


    Yes, you can either specify input style attributes with either the STYLE or the CLASS arguments of the AddInput function.

    If you want to change the STYLE or CLASS of an input field that is not valid, you can use the SetInputProperty() function for that after calling Validate().


    > Another design-thing is that i prefer to
    > otupot the error-messages shown as
    > alt-tags behind a icon-Graphic behind
    > each form-field.


    Sure, you mark invalid fields with whatever HTML code you want.

    [reply] [top]


[»] validate as group
by Conrad - Apr 28th 2003 05:59:09

Hallo,

thanks for your class, it is very helpful.

Is it possible to group inputs, e.g. of select and text type, in such a way, that I can validate whether only one of them contains a value while the other does not? So far I have only been able to create a workaround using a client javascript function and similar input names.

Cheers,

Conrad

[reply] [top]


    [»] Re: validate as group
    by Manuel Lemos - Apr 28th 2003 07:06:43


    > Is it possible to group inputs, e.g. of
    > select and text type, in such a way,
    > that I can validate whether only one of
    > them contains a value while the other
    > does not? So far I have only been able
    > to create a workaround using a client
    > javascript function and similar input
    > names.


    There is the SubForm attribute that can be used to group fields, so when you submit a form with a submit button of the same SubForm, it will only validate the fields of the same SubForm.

    There is also the ValidateOptionalValue that makes the form only validate fields that are different of the specified value.

    I am not sure if this is what you want.

    [reply] [top]


[»] Bugs when using Smarty {include} capability
by berendes - Feb 18th 2003 21:22:16

forms.php isn't completely compatible with the Smarty {include} capability (nested templates).

I haven't tested this thoroughly, but this is what I've noticed.

1. if f1.tpl {include}'s f2.tpl, and f2.tpl has no {input} commands, php generates a fatal error (For instance: Call to a member function on a non-object in /.../templates_c/%%-84/%%-846696630/f2.tpl.php on line 186) after seemingly rendering all of f2.tpl correctly.

Workaround: put a dummy {input} command at the end of f2.tpl (perhaps elsewhere as well, haven't tested).

2. If f1.tpl {include}s f2.tpl, like so
...html and formsgen code ...
{input name="somefield"}
...more generic html and smarty code...
{include file="f2.tpl"}

then f1.tpl is rendered as if it had been written:
...html and formsgen code ...
{input name="somefield"}
{include file="f2.tpl"}
...more generic html and smarty code...

I.e. the include'd code is inserted in the wrong place.

Workaround: put a dummy {input} right before the {include} command, and it stays put, e.g.

...html and formsgen code ...
{input name="somefield"}
...more generic html and smarty code...
{input name="dummy"}
{include file="f2.tpl"}

seems to render as expected.

[reply] [top]


    [»] Re: Bugs when using Smarty {include} capability
    by Manuel Lemos - Mar 16th 2003 19:39:31


    > forms.php isn't completely compatible
    > with the Smarty {include} capability
    > (nested templates).

    Can you give me the smallest example that presents this problem?

    [reply] [top]


[»] Recovering values for select, multiple fields?
by berendes - Jan 24th 2003 13:58:28

When I define a select/multiple field in the test_smarty_form, like so:
$testform->AddInput(array(
"TYPE"=>"select",
"NAME"=>"MatchingFundType",
"ID"=>"MatchingFundType",
"SIZE"=>"9",
"MULTIPLE"=>"1",
"OPTIONS"=>array( "community"=>"community", "ecdev"=>"economic development", "empworkdev"=>"employment"),
"LABEL"=>"Check one or more categorical <u>s</u>ources of matching funds",
"ACCESSKEY"=>"s"
));
I don't get the values out of the submission automatically. Am I missing a trick, or do I have to use the Changes property specifically to extract info from select/multiple fields? (or some other way)?

[reply] [top]


    [»] Re: Recovering values for select, multiple fields?
    by Manuel Lemos - Jan 28th 2003 21:07:36


    > I don't get the values out of the
    > submission automatically. Am I missing a
    > trick, or do I have to use the Changes
    > property specifically to extract info
    > from select/multiple fields? (or some
    > other way)?
    >

    Use GetInputValue() function. For SELECT MULTIPLE fields it will return an array with all selected values.

    [reply] [top]


      [»] GetValue & Select/Multiple & magic_quotes_gpc interact badly
      by berendes - Jan 30th 2003 12:38:18

      I think I've found the disconnect. The GetValue function in forms.php has this near the end:


      > if(function_exists("ini_get")
      > && intval(ini_get("magic_quotes_gpc")))
      > $value=StripSlashes($value);

      so if the GPC value being retrieved is an Array (like a Select/Multiple) , StripSlashes will return "Array", rathern than array ("option1", "option2").

      and you won't see this behavior unless you've got magic_quotes_gpc set.

      [reply] [top]


        [»] Re: GetValue & Select/Multiple & magic_quotes_gpc interact badly
        by Manuel Lemos - Feb 16th 2003 00:56:50


        > I think I've found the disconnect. The
        > GetValue function in forms.php has this
        > near the end:
        >
        >
        > % if(function_exists("ini_get")
        > % &&
        > intval(ini_get("magic_quotes_gpc")))
        > %
        > $value=StripSlashes($value);
        >
        >
        > so if the GPC value being retrieved is
        > an Array (like a Select/Multiple) ,
        > StripSlashes will return "Array",
        > rathern than array ("option1",
        > "option2").
        >
        > and you won't see this behavior unless
        > you've got magic_quotes_gpc set.
        >
        >

        You are right. I have just made time and uploaded a fixed version.

        [reply] [top]