Form validation in codeigniter does not seem DRY |
When you said validate more than one _post variable, I thought you were talking about more than one $_POST dataset. Reading your first provided link I now see what you mean.
You need two values from your $_POST dataset to validate a specific value. Creating a custom validation rule should do the trick. I would suggest extending the validation class and adding your custom method. Example: PHP Code: public function my_custom_validation($validate_this, $_post_key) { To use it do: PHP Code: $this->form_validation->set_rules('url', 'URL', 'trim|xss_clean|my_custom_validation[post_key]'); You add my_custom_validation to your rules and between the [] you place the name of the field or fields that must also be used for the validation. When using multiple fields use a . to seperate the names You should now be able to validate more than one post value within the same validation method |
Welcome Guest, Not a member yet? Register Sign In |