RE: [SMARTY] SmartyValidate 2.6 and Smarty 2.6.12 doesn't work ...
| From: | Reynier Perez Mira | Date: | Mon, 30 Jan 2006 16:56:13 +0000 |
| Subject: | RE: [SMARTY] SmartyValidate 2.6 and Smarty 2.6.12 doesn't work ... | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-13286@lists.php.net to get a copy of this message | ||
Oww !!!!!, ... This is very help to me because I not understand yet how SmartyValidate works. Now I
got. The problems in my code still appear.
1) I recheck my code again. See below changes:
PHP
---
<?
include_once('set_app.php');
// Register form and validators
if(empty($_POST)){
SmartyValidate::connect($tpl, true);
// Register some validators
SmartyValidate::register_validator('fnombre','uNombre','notEmpty');
SmartyValidate::register_validator('fapellidos','uApellidos','notEmpty');
// This TPL file contains the form elements and I include in a main file when action register is
called from URL. For example: index.php?a=register
$tpl->assign('display','register');
} else {
SmartyValidate::connect($tpl);
// Check if form was validate or not
if(SmartyValidate::is_valid($_POST)) {
// If was then disconect from SmartyValidate
SmartyValidate::disconnect();
// Stop execution and send message
die('Form validate');
} else {
// If not redraw the form again
$tpl->assign($_POST);
// Redraw form and send message
print_r('Form not ok');
$tpl->assign('display','register');
}
}
$tpl->display('main.tpl');
$tpl->clear_all_assign();
?>
main.tpl:
---
{if $display eq ""}
{include file="home.tpl"}
{elseif $display eq "buy_now"}
{include file="buy_now.tpl"}
{elseif $display eq "register"}
{include file="register.tpl"}
{elseif $display eq "login"}
{include file="login.tpl"}
{/if}
This works fine, because when I call index.php?a=register register.tpl file is include, so I discard
that this was the error.
register.tpl
---
<fieldset>
<legend>Registro de nuevos usuarios</legend>
<form name="uRegister" id="uRegister" method="post"
action="uoptions.php?a=nuevo">
<table align="center" cellpadding="1" cellspacing="1">
<tr>
<td width="89" class="derecha">Nombre:</td>
<td width="144">
<input type="text" name="uNombre" id="uNombre"
size="35" maxlength="35" value="{$uNombre}">
{validate id="fnombre" field="uNombre" message="El campo Nombre no
puede estar vacio"}
</td>
</tr>
<tr>
<td class="derecha">Apellidos:</td>
<td>
<input type="text" name="uApellidos" id="uApellidos"
size="35" maxlength="45" value="{$uApellidos}">
{validate id="fapellidos" field="uApellidos" message="El campo
Apellidos no puede estar vacio"}
</td>
</tr>
<tr><td colspan="2" class="center"><input
type="submit" name="btn_Send" value="Enviar"></td></tr>
</table>
</form>
</fieldset>
So I can't find the error, because all if in the same way you say me. I just change the example
values from your code to match with my code. I check the session var and all are registered: form,
validate criteria .... So can't really understand what I'm doing wrong.
Hint: I cut some code for do more readable and easy.
Regards
ReynierPM
4to. año Ing. Informática
Usuario registrado de Linux: #310201
*************************************************************************
El programador superhéroe aprende de compartir sus conocimientos.
Es el referente de sus compañeros. Todo el mundo va a preguntarle y él, secretamente, lo fomenta
porque es así como adquiere su legendaria
sabiduría: escuchando ayudando a los demás...