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

Validate prefilled fields

 
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
gopher
Smarty Rookie


Joined: 04 Mar 2005
Posts: 23

PostPosted: Mon Apr 11, 2005 1:57 pm    Post subject: Validate prefilled fields Reply with quote

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


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

PostPosted: Mon Apr 11, 2005 2:45 pm    Post subject: Reply with quote

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


Joined: 04 Mar 2005
Posts: 23

PostPosted: Mon Apr 11, 2005 3:28 pm    Post subject: Reply with quote

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
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