|
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 |
dubhunter Smarty Rookie
Joined: 09 Aug 2007 Posts: 13 Location: Santa Monica, CA
|
Posted: Thu Aug 09, 2007 5:18 pm Post subject: Easy way to assign form post to next template |
|
|
This is a great one when server side validation is need, or you would like to forward to a thank you page.
Code: |
//method from PageController Class
private function assignPost($args)
{
$this->smarty->caching = false;
foreach ($args as $k => $v)
$this->smarty->assign($k, stripslashes($v));
}
//USAGE:
//$this->assignPost($_POST);
|
|
|
Back to top |
|
Celeb Administrator
Joined: 17 Apr 2007 Posts: 1025 Location: Vienna
|
Posted: Fri Aug 10, 2007 6:19 am Post subject: |
|
|
What's wrong with
Code: | $smarty->assign($_POST) |
What do you need the stripslashes() for? I know its function but why do you need it here in particular? _________________ Darn computers always do what I tell them to instead of what I want them to do. |
|
Back to top |
|
dubhunter Smarty Rookie
Joined: 09 Aug 2007 Posts: 13 Location: Santa Monica, CA
|
Posted: Fri Aug 10, 2007 7:00 am Post subject: |
|
|
Celeb wrote: | What's wrong with
Code: | $smarty->assign($_POST) |
What do you need the stripslashes() for? I know its function but why do you need it here in particular? |
You are right. There is nothing wrong with it. I was not aware that associative arrays were available in any context besides
Code: | {$foo.no}, {$foo.label}
{$contact.id}, {$contact.name},{$contact.email} |
The stripslashes() was in there for magic_quotes_gpc being on in the .ini file. _________________ http://dontblinkdesign.com |
|
Back to top |
|
Celeb Administrator
Joined: 17 Apr 2007 Posts: 1025 Location: Vienna
|
Posted: Fri Aug 10, 2007 7:54 am Post subject: |
|
|
I usually use the above line when validating HTML forms with SmartyValidate and I've got magic_quotes_gpc on too.
Works like a charm You just gotta love Smarty _________________ Darn computers always do what I tell them to instead of what I want them to do. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sat Aug 11, 2007 2:30 am Post subject: |
|
|
magic quotes === evil |
|
Back to top |
|
Celeb Administrator
Joined: 17 Apr 2007 Posts: 1025 Location: Vienna
|
Posted: Sat Aug 11, 2007 9:22 am Post subject: |
|
|
Aye .. it's not my call though. _________________ Darn computers always do what I tell them to instead of what I want them to do. |
|
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
|