RE: [SMARTY-DEV] Smarty html forms validation builtin request
| From: | Simon H | Date: | Mon, 31 Mar 2003 23:45:43 +0000 |
| Subject: | RE: [SMARTY-DEV] Smarty html forms validation builtin request | ||
| References: | 1 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-1060@lists.php.net to get a copy of this message | ||
Hi Ernani
SmartyForm has a well documented working example (with some config
settings of course) in CVS...I think you should find that SmartyForm
will do most, if not all of what you need.
The current package and official docs are out-dated. CVS verson is
working fine! Client-side email validation has been added, also a
pattern valdation (alphanumeric and the like) and some other stuff.
Check the usage examples in each of the validation functions.
Also a formlabel function has been added to include client and server
side label highlighting in validation...this works nice, but some
changes will likely happen here in the future. A form error function has
been added which can be placed anywhere in the form to show all form
errors. All valdation functions are documetned with examples.
Have a look at the webcvs of smartyform:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/smartyform/smartyform/exa
mples/medium_example/
Or get the whole CVS tree. The readme in this example and the inline
docs in the templates explain everything so far.
If you have any ideas or suggestions (other than the lack of docs of
course) for SmartyForm v.2 please post to the smartyform-general list:
http://sourceforge.net/mail/?group_id=62399
Hope this helps!
Simon H
> -----Original Message-----
> From: Ernani Joppert Pontes Martins
> [mailto:ernani_listas@terra.com.br]
> Sent: Monday, March 31, 2003 11:10 PM
> To: smarty-dev@lists.php.net
> Subject: Re: [SMARTY-DEV] Smarty html forms validation builtin request
>
>
> Ok, thanks
>
> The only problem of this function is that it is not well documented.
>
> Perhaps some builtin function should get smarty more powerfull.
>
> []'s
>
> Ernani
>
> "Monte Ohrt" <monte@ispi.net> escreveu na mensagem
> news:1049123228.18551.11.camel@lena.ispi.prv...
> > Yes you can, that's what custom functions are for. I
> believe there are
> > already some efforts with form validation functions for
> smarty, such
> > as smartyform.sourceforge.net.
> >
> > Monte
> >
> > On Sun, 2003-03-30 at 23:53, Ernani Joppert Pontes Martins wrote:
> > > Hi there,
> > >
> > > I was trying to change my Smarty.Compiler class to do
> some built in
> > > javascript routines to validate forms.
> > >
> > > The better I got was what I need to do to make it work correctly.
> > >
> > > Dear Monte Ohrt or Andrei Zmievski,
> > >
> > > Do you both like this idea?
> > >
> > > The thing is that the method compile file call the method
> > > compile_tag method. so then I've added a {form...} case in that
> > > method so it does interpret
> the
> > > tags {form name="x" method="..." ..} and either a closing case to
> "/form"
> > > tag that produces a simple </form>
> > >
> > > Here is the need, the compile tag only process smarty
> tags, leaving
> > > html code there.
> > >
> > > The need is to process first time the {form} {input} {select} tags
> finding a
> > > validate parameter equals to true
> > >
> > > like this
> > >
> > > {form name="test" validate="true"}
> > > Test {input type="text" name="testtext" size="10"
> > > validate="true" required="The field test is required."} {/form
> > > validate="true"}
> > >
> > > to change to
> > > <script language="javascript">
> > > function validateForm(obj)
> > > {
> > > if(document.testtext.value == "")
> > > {
> > > alert{"The field test is required.");
> > > }
> > > }
> > > </script>
> > >
> > > <form name="test" onsubmit="validateForm(this);">
> > > <input type="text" name="testtext" size="10">
> > > </form>
> > >
> > > The main goal of this procedure is to read all the template
> > > searching
> for
> > > {form validate="true"}
> > > and change it to:
> > > <script language="javascript">
> > > function validateForm(obj)
> > > {
> > >
> > > Then search for {input type="any" name="it"
> > > validate="true"
> > > required="Message"} and change it to:
> > > if(document.testtext.value == "")
> > > {
> > > alert{"Message");
> > > }
> > >
> > > And then again search for {/form} and change it to:
> > > </script>
> > >
> > > With this we achieved the script validation and if it was
> assigned
> > > to
> the
> > > template like this :
> > >
> > > <html>
> > > <head>
> > > {scriptvalidate}
> > > </head>
> > >
> > > The code should be transformed to :
> > >
> > > <html>
> > > <head>
> > > <script language="javascript">
> > > function validateForm(obj)
> > > {
> > > if(document.testtext.value == "")
> > > {
> > > alert{"The field test is required.");
> > > }
> > > }
> > > </script>
> > > </head>
> > >
> > > The main goal is to compile javascript validation first if exists
> > > then compile all tags like it does already only adding form /form
> > > input select and textarea cases on the _compile_tag method.
> > >
> > > And assign this javascript code to a smarty reserved
> variable that
> > > if defined in a part of each header template it assign it
> and change
> > > the
> code.
> > >
> > > With this we can add more functionality to smarty and to
> php either
> since it
> > > will be more complete.
> > > Then we can implement {input validate="true" required="yes"
> > > emailvalue="true"} routines to validate emails, integer numbers,
> > > etc.
> etc.
> > > etc.
> > >
> > > That's my 2 cents
> > >
> > > Ernani
> > --
> > Monte Ohrt <monte@ispi.net>
> >
>
>
>
> --
> Smarty Development Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>