简体   繁体   中英

Lithium PHP framework - validation rule doesn't trigger on existing field …

I have a form for changing password. So the POST data include the fields password and passwordConfirm .

Also I have validation rules for these 2 properties in the Users model, and they work fine on registration - ie creating new user. But when updating existing user - they don't trigger.

In that case - I dumped the data of the entity inside the save() method of the basic model class:

$entity->data()

I see that both submitted fields/properties are already there ... and they are different. Immediately after that I dumped

$entity->validates()

and this gives me true ?!?! ...

How is that even possible ??? ...

PS: I'm dumping inside a core class of the framework ... and not some 3rd party library ...

I found the reason for the problem :) ...

On the validation rules, defined in the model by the previous developers, there was this clause:

'on' => 'create'

which was causing the validation rule not to trigger when editing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM