Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

How to use SmartyValidate to make multiple page forms?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
timmerk
Smarty Regular


Joined: 06 Mar 2005
Posts: 36

PostPosted: Tue Mar 08, 2005 2:57 am    Post subject: How to use SmartyValidate to make multiple page forms? Reply with quote

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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Mar 08, 2005 2:47 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Mar 08, 2005 3:11 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Mar 08, 2005 3:52 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
timmerk
Smarty Regular


Joined: 06 Mar 2005
Posts: 36

PostPosted: Tue Mar 08, 2005 4:15 pm    Post subject: Reply with quote

Cool! Thanks! I will try it out tonight and try to get back to you.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Add-ons All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP