|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
timmerk Smarty Regular
Joined: 06 Mar 2005 Posts: 36
|
Posted: Tue Mar 08, 2005 2:57 am Post subject: How to use SmartyValidate to make multiple page forms? |
|
|
Is there an easy way to create a form and have multiple pages? I know another PEAR project builds on HTML_QuickForm to do this. It's called "HTML_QuickForm_Controller".
Thanks! |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Mar 08, 2005 2:47 pm Post subject: |
|
|
Off the top of my head, I don't see why a multiple page form wouldn't work.
You put your validator tags on each page of the form that correspond to the fields on that page. ?? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Mar 08, 2005 3:11 pm Post subject: |
|
|
actually I think you'd have to register each page separately:
[php:1:8377a067eb]SmartyValidate::connect($smarty);
SmartyValidate::register_form('page1');
SmartyValidate::register_form('page2');
SmartyValidate::register_form('page3');[/php:1:8377a067eb]
Then in the templates:
page1.tpl
Code: | {validate form="page1" ...} |
page2.tpl
Code: | {validate form="page2" ...} |
And in PHP:
[php:1:8377a067eb]switch($myform) {
case 'page1':
SmartyValidate::is_valid($_POST,'page1');
...
break;
case 'page2':
SmartyValidate::is_valid($_POST,'page2');
...
break;
}[/php:1:8377a067eb]
So you'd be registering each "page" as a separate form. It still works as one form conceptually though, to move an element from one page to another, change the form attribute on the validate tag. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Mar 08, 2005 3:52 pm Post subject: |
|
|
CVS is now updated to handle multi-page forms.
If you want to do multi-page forms, prior to each page being displayed you call the function:
[php:1:45347208b8]
// pass form name as optional 2nd param
SmartyValidate::set_page('2');
[/php:1:45347208b8]
Then on each validator, you must have a page attr corresponding to its page:
Code: | {validate id="foo" page="2" message="foo needs a value"} |
Give it a shot. I did some minimal testing and it look to be working OK. |
|
Back to top |
|
timmerk Smarty Regular
Joined: 06 Mar 2005 Posts: 36
|
Posted: Tue Mar 08, 2005 4:15 pm Post subject: |
|
|
Cool! Thanks! I will try it out tonight and try to get back to you. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|