ikkez / f3-validation-engine

Validation engine for Cortex and the PHP Fat-Free Framework
GNU General Public License v3.0
12 stars 2 forks source link

Cortex Update doesn't work #6

Open Wh00ps13 opened 2 years ago

Wh00ps13 commented 2 years ago

When update a row using validation engin it won't execute the update it does execute the addmessage instruction is it should be valid. i set the levels so that password is set with level "0"

I figured out when ising "copyfrom" before the "update" in the if state it works.

function _updatePass($uid){
        $user = new \Models\Users();
        $user->copyFrom('POST','password');
        if($user->validate(0)){
            $user->load(array('uid=?',$uid));
            $user->update();
            $this->flash->addMessage($this->f3->get('DICT.alerts.userUpdateSucces'), 'success');
        }
    }
ikkez commented 2 years ago

This is because you do a $user->load after the copyfrom and before the ->update()... of course the update wont update anything then, because you have just loaded the record from the database and the mapper only updates when a field was changed.

Wh00ps13 commented 2 years ago

Creat that seems to do the trick.

I'm also trying to use the levels. got multiple levels setup 0,1,2,3 is there a possibility to use 2,3 and not 0,1 ? The documentation says something with $level_op but i don't understand that one.

ikkez commented 2 years ago

yes.. if you use level 2 and set $level_op (comparison operator) to >= it's should only process level 2 and above.