Your syntax is correct, but I'm going to guess and say that your DB schema does not have a 'password_confirm' column so you are trying to add a rule to a field that doesn't exist Regardless, the right place to perform password confirm matching validation is not in your model but as extra validation that is passed to your model in your controller when you attempt to save Put this in your user controller: $user = ORM::Factory('user'); // Don't forget security, make sure you sanitize the $_POST data as needed $user->values($_POST); // Validate any other settings submitted $extra_validation = Validation::factory( array('password' => Arr::get($_POST, 'password'), 'password_confirm' => Arr::get($_POST, 'password_confirm')) ); $extra_validation->rule('password_confirm', 'matches', array(':validation', 'password_confirm', 'password')); try { $user->save($extra_validation); // success } catch (ORM_Validation_Exception $e) { $errors = $e->errors('my_error_msgs'); // failure } Also, see the Kohana 3.1 ORM Validation documentation for more information.
Your syntax is correct, but I'm going to guess and say that your DB schema does not have a 'password_confirm' column so you are trying to add a rule to a field that doesn't exist. Regardless, the right place to perform password confirm matching validation is not in your model but as extra validation that is passed to your model in your controller when you attempt to save. Put this in your user controller: $user = ORM::Factory('user'); // Don't forget security, make sure you sanitize the $_POST data as needed $user->values($_POST); // Validate any other settings submitted $extra_validation = Validation::factory( array('password' => Arr::get($_POST, 'password'), 'password_confirm' => Arr::get($_POST, 'password_confirm')) ); $extra_validation->rule('password_confirm', 'matches', array(':validation', 'password_confirm', 'password')); try { $user->save($extra_validation); // success } catch (ORM_Validation_Exception $e) { $errors = $e->errors('my_error_msgs'); // failure } Also, see the Kohana 3.1 ORM Validation documentation for more information.
Thanks a lot for your answer, it worked nice. – Alejandro García Iglesias May 27 at 20:24.
The use of a second validation object is necessary since save() causes the internal model validation object to be checked. This means that rules added to the validation object being checked from a validation rule will be ignored (Validation->check() imports the rules into local scope before looping). Since the data itself is technically another object (in the sense of object relationships, it has its own dataset that needs validation) the ideal solution would be to find a way to create a real model that saves the data.
There are numerous other benefits to saving data with proper database column definitions, not least if you need to perform data property lookups, make in-situ changes etc. (which would otherwise require unserializing the data column, potetnailly in all rows). Create a model that represents the data object and add rules to it, using check() to validate the data (problem: will require a lot of maintenance, no real-world table means columns must be manually defined). Set the data as real columns in the Admin model, and use a filter that will convert it into the data column on set (problem: again, must manually define the columns and exclude the additional columns from the save operation).
I hope this is of some use. The Kohana ORM save() method permits the inclusion of an "extra" validation object, which is merged into the main ORM validation object namespace. This is documented briefly here.
While in this example you must still create another validation object, you are now able to catch all exceptions in a single block. I would recommend using var_dump() or similar on $e->errors() to check the namespace if you are using i18n messages to provide a human-readable error message. You should find that a namespace called "_external" has been created in the response.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.