Jump to content


xheradon

Member Since 01 Mar 2017
Offline Last Active Jul 02 2018 08:49 AM
-----

Topics I've Started

Prevent using default insert/update method

20 July 2017 - 01:27 PM

Hi, is there any option to prevent the use of the default insert/update... method?

 

I want to do insert and updates manually on before_insert/update callback because I've a specific method for that.

 

Thanks.


Problem with callback in validation rule

01 March 2017 - 09:57 AM

Hi, im trying to check if email is already in use when editing. If email is not changed from edit form all OK, but if email is changed have to check if new email is not already in use. Im trying to set a callback on email validation rule:

$crud->set_rules('email', 'email', 'required|valid_email|callback_email_check');

Then I've (I have to modify, got from another post)

public function email_check($email) {
        $primary_key = $this->uri->segment(4);     
        dump($email);
        dump($primary_key);
        $this->form_validation->set_message('email_check', 'The email - ' . $email . ' already is assigned to some other user');
        $rows = $this->cModel->getAllFor('retailer_acct', 'email', $email);
        if(!empty($primary_key) && is_numeric($primary_key))
        {
            if(count($rows)>0) {
                if($rows[0]['id'] != $primary_key) {
                    $this->form_validation->set_message('email_check', 'The email - ' . $email . ' already is assigned to some other user');
                    return false;
                }
            }
            return true;
        } else {
            if(count($rows)>0) {
                $this->form_validation->set_message('email_check', 'The email - ' . $email . ' already is assigned to some other user');
                return false;
            } else {
                return true;
            }
        }
    }

But on firebug I've no dumps and returning always: "FIXME('form_validation_email_check')" and "{"success":false,"error_message":"<p>FIXME('form_validation_email_check')<\/p>\n","error_fields":{"email":"FIXME('form_validation_email_check')"}} JSON.

 

Any help? I think is not calling callback function on validation email... Thanks!

 

EDIT: email field is in another table (i don't know if this has any relation with the problem)