Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Dedicated server web hosting provided by Guru-host.eu.
Newbie syntax question

 
Post new topic   Reply to topic    Smarty Forum Index -> Add-ons
View previous topic :: View next topic  
Author Message
dalp
Smarty Rookie


Joined: 14 Jul 2006
Posts: 8

PostPosted: Fri Jul 14, 2006 8:50 am    Post subject: Newbie syntax question Reply with quote

Ok, I'm not getting my second page form to display validation errors.
The $tpl->assign('error', true); is run but no error is displayed.
I'm assigning the different forms as:
SmartyValidate :: register_form('first_form', true);
SmartyValidate :: register_form('second_form', true);

What could be causing the complication?
The validation is done:

Code:
form.php

init...
...
SmartyValidate :: connect($tpl);
SmartyValidate :: register_form('second_form', true);
SmartyValidate :: register_validator('tv_name', 't_name', 'notEmpty', false, false, false, 'trim', 'second_form');
...
...
if submitted...
...
$data['t_name'] = $_POST['t_name'];
SmartyValidate :: connect($tpl);
if (SmartyValidate :: is_valid($data, 'second_form')) {
   echo "done and done!";
}
else {
   $tpl->assign('error', true);
}

form.tpl
<input type="text" name="t_name" />
{validate form="second_form" id="tv_name" message="Enter a name!"}

No error is displayed..
The first form is identical to the second, but uses "r_name" and "rv_name" instead of "t" and "tv_".

Any help would be greatly appriciated!
Back to top
View user's profile Send private message Visit poster's website
Hielke Hoeve
Smarty Elite


Joined: 06 Jan 2006
Posts: 406
Location: Netherlands

PostPosted: Fri Jul 14, 2006 10:24 am    Post subject: Re: Newbie syntax question Reply with quote

dalp wrote:
The $tpl->assign('error', true); is run but no error is displayed.

Do you display the variable in your template? ( {$error} )
_________________
Debug XHTML Compliance
SmartyPaginate
Smarty License Questions
---
(About Unix) The learning curve is full of aha! moments, such as that glorious day that the full beauty of grep and, later, find is revealed in all its majesty. --- Robert Uhl <ruhl@4dv.net>
Back to top
View user's profile Send private message
dalp
Smarty Rookie


Joined: 14 Jul 2006
Posts: 8

PostPosted: Fri Jul 14, 2006 10:35 am    Post subject: Re: Newbie syntax question Reply with quote

Hielke Hoeve wrote:
Do you display the variable in your template? ( {$error} )


No, the $error is just set to true.
Shouldn't the error be displayed by:
form.php:
SmartyValidate :: register_validator('tv_name', 't_name', 'notEmpty', false, false, false, 'trim', 'second_form');
and
form.tpl:
{validate form="second_form" id="tv_name" message="Enter a name!"}
Back to top
View user's profile Send private message Visit poster's website
dalp
Smarty Rookie


Joined: 14 Jul 2006
Posts: 8

PostPosted: Fri Jul 14, 2006 2:16 pm    Post subject: Reply with quote

Hi again!

I've experimented further with the error and come to some valuable information i think.

The first form i call will allways work, while the other won't.
Here form 1 Works, all of it fields, even fields validated after these rows:
Code:
{validate form="form1" id="t1_name" message="Enter a name!"}
{validate form="form2" id="t2_name" message="Enter a name!"}

Here form2 works, all of it fields:
Code:
{validate form="form2" id="t2_name" message="Enter a name!"}
{validate form="form1" id="t1_name" message="Enter a name!"}


For some reason, only the first form i validate in my template will display errors, though both will correctly validate it's fields.

Anyone know what the problem might be?
Back to top
View user's profile Send private message Visit poster's website
dalp
Smarty Rookie


Joined: 14 Jul 2006
Posts: 8

PostPosted: Thu Jul 20, 2006 10:28 am    Post subject: Reply with quote

This is, sadly, still an unresolved issue.
Should it be possible to print validation errors for two different forms on the same page?
Back to top
View user's profile Send private message Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5613
Location: Toronto, Canada

PostPosted: Thu Jul 20, 2006 3:29 pm    Post subject: Reply with quote

Do you mean you want both forms to show errors on a single submit? (Only one form is ever submitted during a submit.)
Back to top
View user's profile Send private message
dalp
Smarty Rookie


Joined: 14 Jul 2006
Posts: 8

PostPosted: Thu Jul 27, 2006 12:04 pm    Post subject: Reply with quote

Hi boots.

No, i only want the form that is submitted to display errors, of course.
But the first form to be validated will be the only one able to display errors.
Therefor, if the second form to be validated is submitted, it won't display errors, even if there are some.

Am I making sence?

If I'm allowed to PM you, I can show you the page itself.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    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