RE: [SMARTY] SmartyValidate 2.6 and Smarty 2.6.12 doesn't work ...
| From: | Reynier Perez Mira | Date: | Mon, 30 Jan 2006 15:54:39 +0000 |
| Subject: | RE: [SMARTY] SmartyValidate 2.6 and Smarty 2.6.12 doesn't work ... | ||
| Groups: | php.smarty.general php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-13282@lists.php.net to get a copy of this message | ||
Hi to every body again. I still with problems. I don't know why this happened. If any can help
me?
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...
-----Mensaje original-----
De: Reynier Perez Mira
Enviado el: Friday, January 27, 2006 9:40 PM
Para: Monte Ohrt
CC: smarty-general@lists.php.net
Asunto: RE: [SMARTY] SmartyValidate 2.6 and Smarty 2.6.12 doesn't work ....
Hi:
I still with SmartyValidate problems. After a rechecking for entire documentation in
"Incutio", I found some elements to test if I do the right or not. The first is test is
form are registered or not. So I rewrite again my old code and this is the way:
******************************************************************
if(empty($_POST)){
SmartyValidate::connect($tpl, true);
/* If I understand doc the form have not name is call 'default' but my form
has a name and a id in this way: <form name="uRegister" id=" uRegister */
">. So I need to register my form in the way under */
SmartyValidate::register_form('uRegistro');
/* Then I test if form was register or not */
if(!SmartyValidate::is_registered_form('uRegistro')){
echo "Don't registered yet";
}else{
echo "Registered form";
}
/* This print "Registered form" */
/* Then I register some validators needed */
SmartyValidate::register_validator('fnombre','uNombre','notEmpty');
SmartyValidate::register_validator('fapellidos','uApellidos','notEmpty');
SmartyValidate::register_validator('fdireccion','uDireccion','notEmpty');
SmartyValidate::register_validator('fcorreo','uCorreo','isEmail');
SmartyValidate::register_validator('fusuario','uUsuario','notEmpty');
SmartyValidate::register_validator('fpassword','uPsw1:uPsw2',
'isEqual');
/* I assign a template var because in a template according to the value taken for this var (display)
I include some files */ $tpl->assign('display','register');
}else{
/*Here I don't change nothing because is the standard procedure for follow*/
SmartyValidate::connect($tpl);
if(SmartyValidate::is_valid($_POST)) {
SmartyValidate::disconnect();
$tpl->display('success.tpl');
} else {
$tpl->assign($_POST);
$tpl->display('form.tpl');
}
}
******************************************************************
So I rechecking again documentation and find another sutff but now about templates. So I
reprogramming again my old code and now this is:
******************************************************************
<!-- User register form -->
<fieldset><legend>{#REGISTER_TITLE#|escape:"htmlall"}</legend>
<form name="uRegistro" id="uRegistro" method="post"
action="inser_user.php"> <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}">
/* In doc I found that {validate} tags require a parameter call criteria, this is optional or not?
I'm lost here at this point. So I add this parameter to all my {validate} tags */ {validate
id="fnombre" criteria="notEmpty" 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"
criteria="notEmpty" message="El campo Apellidos no puede estar vacio"}
</td></tr> <tr><td
class="derecha">Dirección:</td>
<td><textarea name="uDireccion" id="uDireccion" cols="35"
rows="5">{$uDireccion}</textarea> {validate id="fdireccion"
criteria="notEmpty" message="El campo Direccion no puede estar vacio"}
</td></tr> <tr><td class="derecha">eCorreo:</td>
<td><input type="text" name="uCorreo" id="uCorreo"
size="45" maxlength="150" value="{$uCorreo}"> {validate
id="fcorreo" criteria="isEmail" message="El campo Correo Electrónico no
puede estar vacio"} </td></tr> <tr><td
class="derecha">Usuario:</td> <td><input type="text"
name="uUsuario" id="uUsuario" size="35" maxlength="45"
value="{$uUsuario}"> {validate id="fusuario" criteria="uUsuario"
message="El campo Usuario no puede estar vacio"} </td></tr> <tr><td
class="derecha">Contraseña:</td> <td><input type="password"
name="uPsw1" id="uPsw1" size="35" maxlength="150"
value="{$uPsw1}"> {validate id="fpassword" criteria="notEmpty"
message="Los siguientes errores han ocurrido: El campo contraseña esta vacio o las
contraseñas no coinciden"} </td></tr> <tr><td
class="derecha">Confirmar contraseña:</td> <td><input
type="password" name="uPsw2" id="uPsw2" size="35"
maxlength="150" value="{$uPsw2}"> </td></tr> <tr><td
colspan="2" class="center"><input type="submit"
name="btn_Send" value="Enviar"></td></tr>
</table></form></fieldset>
******************************************************************
So as you can see apparently nothing is wrong here, but when I send the form is sending without any
validation. It means that if I leave all fields empty nothing happen and the form go where they was
send, to inser_user.php script. So if any body can help, I really miss some part of the
documentation file or simply I have mistakes in my code?
Best,
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...
--
Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php