Es muy probable que necesitemos comparar ciertos parámetros cuando estamos validando un formulario, por ejemplo, podemos querer validar password, entonces, pedimos escribir 2 veces la password, y luego comprobar que ambas son iguales, también podemos querer comparar fechas, por ejemplo, que la fecha de inicio nunca sea mayor a la fecha de término, sólo por nombrar algunas.
En YII, esto lo podemos validar a través del modelo, ya que en este existe la función rules, podemos leer sobre este en http://www.yiiframework.com/wiki/56/#hh7
Leyendo el enlace anterior, podemos darnos cuenta, que para comparar que la fecha de término sea mayor a la inicial, debemos hacer algo como lo siguiente:
array('fer_termino','compare','compareAttribute'=>'fer_inicio','operator'=>'>=','message'=>'Fecha de Término debe ser superior a Fecha de Inicio'),
Lo que hacemos, es que tomamos la fecha_termino, indicamos que lo compararemos con la fecha_inicio, luego indicamos que utilizaremos el operador '>=' (mayor que), si esta regla no se cumple, lanza el mensaje de error especificado en 'message'
1 comentarios:
In this fashion my colleague Wesley Virgin's report launches with this shocking and controversial video.
As a matter of fact, Wesley was in the military-and soon after leaving-he revealed hidden, "mind control" tactics that the government and others used to get everything they want.
These are the exact same methods tons of famous people (notably those who "became famous out of nothing") and the greatest business people used to become wealthy and successful.
You've heard that you use less than 10% of your brain.
That's mostly because the majority of your brain's power is UNCONSCIOUS.
Perhaps this thought has even occurred INSIDE your very own brain... as it did in my good friend Wesley Virgin's brain about 7 years ago, while riding an unlicensed, beat-up bucket of a car with a suspended license and with $3.20 in his bank account.
"I'm so frustrated with going through life paycheck to paycheck! Why can't I become successful?"
You've been a part of those those types of conversations, am I right?
Your success story is waiting to start. All you have to do is in YOURSELF.
CLICK HERE TO LEARN WESLEY'S METHOD
Publicar un comentario