|
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 |
gopher Smarty Rookie
Joined: 04 Mar 2005 Posts: 23
|
Posted: Mon Apr 11, 2005 1:57 pm Post subject: Validate prefilled fields |
|
|
I'm currently working on a pm function, and when I reply/forward pms some parts of the form are obviously already entered (like the message, subject or the recipient). Is there a "nice" way of using the prefilled text as long as the user didn't submit the form, and the one he entered as soon as he did? Or do I have to pass some kind of info to the form, that the user hit submit?
Something like:
php:
if(isset($_POST['send'])) { $smarty->assign('submit', 1); }
tpl:
{if $submit}
<input type="text" name="subject" value="{$subject}"
{else}
<input type="text" name="subject" value="{$PN.subject}">
{/if}
Or am I missing something obvious? ;> |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Apr 11, 2005 2:45 pm Post subject: |
|
|
You might find the default modifier useful:
Code: | <input type="text" name="subject" value="{$subject|default:$PN.subject}"> |
If $subject is empty, then $PN.subject will be used.
http://smarty.php.net/default |
|
Back to top |
|
gopher Smarty Rookie
Joined: 04 Mar 2005 Posts: 23
|
Posted: Mon Apr 11, 2005 3:28 pm Post subject: |
|
|
mohrt wrote: | You might find the default modifier useful:
Code: | <input type="text" name="subject" value="{$subject|default:$PN.subject}"> |
If $subject is empty, then $PN.subject will be used.
http://smarty.php.net/default |
Why didn't I think of that myself, considering I even use default vars myself. I probably was focusing too much on SmartyValidate =)
Thanks mohrt. |
|
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
|