Just a note
'password' => VALID_NOT_EMPTY,
is wrong. You need something like:
'password' => '/^[a-z0-9]{6,30}$/i',
that means minimum 6 symbols, maximum 30, only letters and digits.
On Nov 26, 2:22 am, oracle411 <[EMAIL PROTECTED]> wrote:
> 'password' =>
Some Snipp for user model:
function beforeValidate()
{
if ( isset($this->data[$this->name]['password']) && isset($this-
>data[$this->name]['password2']) )
{
# invalidate empty password2
if ( empty($thi
On 6/30/07, Geoff Ford <[EMAIL PROTECTED]> wrote:
>
>
> actual hex or numeric codes doesn't matter, and then the view and
> __() would format/translate them to the needed display.
I rest my case
Thanks you validated my POV :)
Tarique
==
I realize that there are situtations where different output is
required, but again this is a formatting issue. In these situations
you would use error codes, whether they are the english default or
actual hex or numeric codes doesn't matter, and then the view and
__() would format/translate them
On 6/30/07, Geoff Ford <[EMAIL PROTECTED]> wrote:
>
>
> Yes, you just remove the error index in the view.
>
> And I disagree, Tarique, error message should be _generated_ by the
> model, as it is related to the value of the data.
Well the same model can have several kind of views so
What if your
Yes, you just remove the error index in the view.
And I disagree, Tarique, error message should be _generated_ by the
model, as it is related to the value of the data. The _formatting_ of
the error message should most definately be handled in the view.
On Jun 29, 5:03 pm, "[EMAIL PROTECTED]" <[
Do you have any examples of how this is accomplished? Do i just remove
the error index from the array in the view.. And tarique, i think to
me it seems a matter of opinion whether you have errors in the view or
the model.. Personally i'd rather have them in the model but i'm sure
many people would
On 6/29/07, Geoff Ford <[EMAIL PROTECTED]> wrote:
> Either way you shouldn't set the error message in the view, it should
> be pulled from the models validationErrors
I would like to add a small amendment to the above - You need not set the
error message in the view, it can be pulled from the mo
In 1.2 $form->input() automatically picks up the error message and you
don't need to set error in the view.
In 1.1 I think you need to use $html->errorTag() or something like
that.
Either way you shouldn't set the error message in the view, it should
be pulled from the models validationErrors
O
If i use $this->invalidate("password", "Passwords do not match");
how do i associate that in my view.. Currently my view has
input('password',
array('error' => 'Password must be at least 4
characters.',
'type'=>'password',
it the lines
function beforeSave() {
if ($this->validates()) {
that Grant was talking about;
$this->validates(); is called automatically before it beforeSave()
gets called so your call to $this->validates() is redundant.
On Jun 28, 12:17 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED
That is a good idea about using invalidate. I didnt know i could do it
that way.
And i'm not sure which code you are referring to, but the latest post
with code that i posted i did not call beforeValidate on my own..
Maybe you read that part wrong.. Those were separate functions..
Second of all, i
I would use $this->invalidate('password', "Passwords do not match") -
this way it is just the same as any other validation routine. You
also don't need to call beforeValidate() in your beforeSave, it is
done automatically by Cake when you save.
Your beforeSave is still MD5-ing every password tha
Ok i got it all working now, unsetting the field did work
here is what i did in my model:
function beforeValidate() {
$u = &$this->data['User'];
$p1 = &$u['password'];
$p2 = &$u['password1'];
if ($p1 !
Ok this is what i've added and its not working. beforeSave never gets
called.. I tested by putting a die statement at the top.
Users controller:
function edit_profile() {
$this->User->id = $this->Session->read('User.id');
if (empty($this->data))
{
Good idea grant.. I was wondering how to figure that out.. I'm a bit
unsure what you mean though about having a hashed_password field?
I don't want to put the hashed password into a hidden input in the
form (md5 is known for dictionary attacks, and although this site i'm
sure would never have that
Its $this->User->validates( $this->data ) , not validate. Cake has
a habit of executing any unknown function you call on a model as SQL.
You can still do it all in the model, just use the beforeValidate to
validate the password submitted is ok (number of chars, matches
confirm password etc) an
17 matches
Mail list logo