|
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 |
paradox Smarty n00b
Joined: 25 Sep 2004 Posts: 3
|
Posted: Sat Sep 25, 2004 5:12 am Post subject: Keeping line breaks in a textarea |
|
|
Hello, I am taking a string from a $_POST and then trying to display it within a textarea. The problem is, line breaks seem to vanish.
Here is example code...
Code: | $smarty->assign('textarea', $_POST['string']);
$smarty->display('template.tpl'); |
Say I typed in this string exactly:
"Hello
Welcome."
In a sense it is "Hello\n\nWelcome."
But when passed through to textarea:
Code: |
<textarea>{$textarea|strip}</textarea> |
It displays as "Hello Welcome."
I want it to display in the textarea as:
"Hello
Welcome."
Thank you for your help.
Note: HTML inside a textarea will display as straight code, so nl2br is not a solution. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
|
Back to top |
|
paradox Smarty n00b
Joined: 25 Sep 2004 Posts: 3
|
Posted: Sat Sep 25, 2004 6:12 am Post subject: |
|
|
Well I need to strip slashes because magic quotes are enabled... so anything in POST or GET have slashes added.
I did not think new lines were stripped...
Is there a way to only strip slashes? |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sat Sep 25, 2004 6:18 am Post subject: |
|
|
paradox wrote: | Well I need to strip slashes because magic quotes are enabled... so anything in POST or GET have slashes added.
I did not think new lines were stripped...
Is there a way to only strip slashes? |
Sure, turn off magic quotes
Or just use the PHP function stripslashes() as a modifer:
Code: | {$foo|stripslashes} |
But |strip only deals with whitespacing.
Last edited by boots on Sat Sep 25, 2004 6:22 am; edited 1 time in total |
|
Back to top |
|
paradox Smarty n00b
Joined: 25 Sep 2004 Posts: 3
|
Posted: Sat Sep 25, 2004 6:21 am Post subject: |
|
|
Turning off magic quotes would be bad... security wise.
Thanks for the solution. Much appreciated! |
|
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
|