Forms Plugin
| From: | Alan McFarlane | Date: | Thu, 14 Mar 2002 14:11:02 +0000 |
| Subject: | Forms Plugin | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-3055@lists.php.net to get a copy of this message | ||
I've been looking at create a forms plugin, however several points need to
be addressed. Currently I'm using the following (basic) syntax:
{form_start name="test" action="./test.php" method="post"}
{input_text label="Full Name" name=ctl[full_name] value=$ctl[full_name]
trim=1 empty=0}
{input_text label="Login Name" name=ctl[login_name] value=$ctl[login_name]
strip=1 empty=0}
{input_text label="Login Password" name=ctl[login_password] strip=1 empty=0}
{input_text label="Confirm Password" name=ctl[confirm_password] strip=1
empty=0}
{input_text label="Email Address" name=ctl[email_address] strip=1 empty=0
email=1}
{input_text label="Age" name=ctl[age] value=$ctl[age] strip=1 empty=0
integer=1
{form_end}
Now, the trim, empty, strip and email fields are used for basic javascript
verification:
trim - strips leading and trailing whitespace characters
strip - strips all whitespaces characters
empty - prevents the form from being submitted until a value has been
entered
email - prevents the form from being submitted unless a valid email
address is entered
integer - prevents the form from being submitted unless a valid integer has
been entered
I'm also looking at supporting regular expressions by adding a regex tag:
regex = (-?)[1-9][0-9]* (integers)
regex = [A-Z]+ (letters)
Obviously, I would rather use a
{input_email label="Email Address" name=ctl[email_address]}
But I'm just using input at the momement to save time switching between the
various plugins in my editor :)
Now, the questions:
1) Can anyone see any serious problems with this setup?
2) Is there any obvious extensions, feature requests etc?
3) Does anyone know if it is possible (and if so, how) to write a {/form}
plugin
This would allow:
{form ...}
...
{/form}
4) Can anyone see a method of cleaning up the {input...} tags - They're
rather messy at the momement, and will become even more so once I support
the full HTML DTD syntax.
--
Alan McFarlane
amcfarlane@bigfoot.com