Preview of Form Plugin
| From: | Roberto Berto | Date: | Thu, 04 Apr 2002 20:11:17 +0000 |
| Subject: | Preview of Form Plugin | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-3493@lists.php.net to get a copy of this message | ||
Note:
The Form Plugin isn't only a custom function, but a set of custom functions
and a prefilter.
Download:
http://www.under.com.br/ourcms/form_plugins-release_alpha.zip
Installation:
All php files should be added to your smarty plugin directory. There are a
.tpl example. Try run it to see the Form Plugin in action.
Purpose:
Make all the Form Validation - server and client side (todo)
Printout Validation errors together to the Form if error
Process the Current Form Step and increment Step counter if no error
Form Overview:
{formprocessor name="ProcessorOne"}
{step}
{form name="formTest" action="form.php" method="get"}
{if $form_sucess == FALSE}
{section name=error loop=$form_errors}
{$form_errors[error].element}
{$form_errors[error].key}
{$form_errors[error].value}
{/section}
{/if}
{/form}
{/step}
{step}
{form name="formTest" action="form.php" method="get"}
{/form}
{/step}
{/formprocessor}
- Allways start and end with {formprocessor} tag. This tag may have a name
attribute.
- You can add how many steps you want. {step} is required. Min steps is two.
- You can add text before {form} and after {/form}
- If form return error, $form_sucess will be FALSE
- The errors will be assigned to $form_errors and will have tree parameters:
element - is the name of the form element that have error
key - is the validation type part
value - is the validation value part
All form tags need be called from {} instead <>. If you want a tag have
validation, you should add
the attribute validation to it.
Eg:
{input type="text" name="name" value=$smarty.request.name
validation="min_lenght=4&max_lenght=20"}
Where min_lenght is the type part of validation and 4 is the value part.
The validation will be both min_lenght more than 4 and max_lenght more than
20.
Each validation type will be a file at plugins dir named:
shared.validation.TYPE.php
And the function name should be:
smarty_validation_NAME
Will be passed two parms to the functions:
$element, $value
$element is the element name. Should be used a $_REQUEST["$element"] to get
it value
$value is the value part of validation that is used to compare something.
The function should return FALSE if want return a error, or TRUE if dont
will
return error. Set of TRUE and FALSE is required.
More details soon.
TODO:
- add more validation functions
- create javascript part
- add some javascript validations
- add "auto complete" to change the input value="" and input type=checkbox
and radio CHECKED, etc - when error
Please, comment the Form Plugin. I'm needing your feedback.
Atenciosamente,
----------------------------------------
Roberto Bertó
Under Development
http://www.under.com.br
Tel: 51 32270599
Cel: 51 91169628