Welcome Guest, Not a member yet? Register   Sign In
issue with validation with datamapper
#11

[eluser]johnmerlino[/eluser]
Thanks for response. I actually got things working but I wanted to clean it up a little so I added the magic method __set:


Code:
//controller
            $user->password($this->input->post('password'));
            $user->confirm_password($this->input->post('confirm_password'));


//User model
            protected $password;
            protected $confirm_password;

            public function __set($property,$value){
                $method = "set_{$property}";
                if(method_exists($this, $method)){
                    return $this->$method( $value );
                } else {
                    $this->$property = $value;
                }
            }
        
            public function set_password($pass){
                $this->password = $pass;
            }
            
            public function set_confirm_password($confirmed_pass){
                $this->confirm_password = $confirmed_pass;
            }

The above raises this:

Code:
Fatal error: Uncaught exception 'Exception' with message 'Unable to call the method "password" on the class User' in /Users/johnmerlino/Sites/hmla/system/application/libraries/Datamapper.php:1210 Stack trace: #0 /Users/johnmerlino/Sites/hmla/system/application/controllers/passwords.php(13): DataMapper->__call('password', Array) #1 /Users/johnmerlino/Sites/hmla/system/application/controllers/passwords.php(13): User->password('') #2 [internal function]: Passwords->update() #3 /Users/johnmerlino/Sites/hmla/system/codeigniter/CodeIgniter.php(236): call_user_func_array(Array, Array) #4 /Users/johnmerlino/Sites/hmla/index.php(115): require_once('/Users/johnmer...') #5 {main} thrown in /Users/johnmerlino/Sites/hmla/system/application/libraries/Datamapper.php on line 1210


Messages In This Thread
issue with validation with datamapper - by El Forum - 05-14-2011, 03:44 PM
issue with validation with datamapper - by El Forum - 05-15-2011, 01:22 AM
issue with validation with datamapper - by El Forum - 05-15-2011, 09:25 AM
issue with validation with datamapper - by El Forum - 05-15-2011, 09:49 AM
issue with validation with datamapper - by El Forum - 05-15-2011, 09:58 AM
issue with validation with datamapper - by El Forum - 05-15-2011, 12:16 PM
issue with validation with datamapper - by El Forum - 05-15-2011, 01:44 PM
issue with validation with datamapper - by El Forum - 05-21-2011, 08:31 AM
issue with validation with datamapper - by El Forum - 05-21-2011, 08:52 AM
issue with validation with datamapper - by El Forum - 05-21-2011, 09:02 AM
issue with validation with datamapper - by El Forum - 05-21-2011, 09:51 AM
issue with validation with datamapper - by El Forum - 05-21-2011, 11:26 AM
issue with validation with datamapper - by El Forum - 07-03-2011, 06:24 PM
issue with validation with datamapper - by El Forum - 07-04-2011, 12:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB