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

SmartyValidate: assigning err msg to template variable

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


Joined: 07 Dec 2004
Posts: 23

PostPosted: Mon Dec 27, 2004 11:12 pm    Post subject: SmartyValidate: assigning err msg to template variable Reply with quote

I've implemented the SmartyValidate plugin and am trying to get the template to assign the error message for each form field to a variable. This way I can display the error message anywhere in the template.

Code:


{validate field="name" criteria="notEmpty" assign="error" halt="yes" transform="trim" message="Please provide your name."}
                           
<input type="text" name="name" size="30" value="{$name|escape}">


Elsewhere I have :

Code:

{$error}


However, it's not working. Is there an order in which the assign should appear inside the validate tags {}? Is there a dependency on the .php file? Could not determine the answer from the doc.
Back to top
View user's profile Send private message
mgm_03
Smarty Rookie


Joined: 07 Dec 2004
Posts: 23

PostPosted: Mon Dec 27, 2004 11:19 pm    Post subject: Reply with quote

Now..I have this situation:

Submitting a blank form results in the first form field err message displayed (where I expect it to be). Then, putting a value in that form field and submitting should still return an error message since the second form field is still blank (all fields are required). However, there is no error message this time.

Not sure what I could've screwed up.

Code:

 <div class="contact">
 Your Name<br />
 {validate field="name" criteria="notEmpty" assign="error" halt="yes" transform="trim" message="Please enter your name."}
                           
 <input type="text" name="name" size="30" value="{$name|escape}">
 </div>
 <div class="contact">
 {validate field="subject" criteria="notEmpty" assign="error" halt="yes" transform="trim" message="Please enter a subject"}
 Subject<br />
 <input type="text" name="subject" size="30" value="{$subject|escape}">
 </div>
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