Welcome Guest, Not a member yet? Register   Sign In
Form Validation - Callback to a Model?
#3

Hello Zeff,

at the moment I extend the CI_Form_validation which make it possible to access the is_unique_email method:

PHP Code:
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class 
MY_Form_validation extends CI_Form_validation
{    
    public function 
is_unique_email($value)
    {
        return 
$this->CI->User_model->is_unique_email($value);
    }


form_validation.php:

PHP Code:
<?php
$config 
= array
{
    
'error_prefix' => '',
    
'error_suffix' => '',
    
'create_user' => array
    {
        array
        (
            
'field'     => 'email',
            
'label'     => 'E-Mail',
            
'rules'     => 'trim|required|max_length[70]|valid_email|is_unique_email'
        
),
    },


But I don't unterstand how I can call model method from this rule config array directly.
Reply


Messages In This Thread
RE: Form Validation - Callback to a Model? - by minsk832 - 02-01-2018, 06:58 PM



Theme © iAndrew 2016 - Forum software by © MyBB