Welcome Guest, Not a member yet? Register   Sign In
form validation behavior
#3

(This post was last modified: 11-28-2016, 08:14 AM by Avenirer. Edit Reason: styling the replyu )

Hello, @Edel

I don't know if this helps you, but I've made a repo with custom form validation rules that I've used in the past at the following url: https://github.com/avenirer/MY_Form_validation-for-CI

You copy the MY_Form_validation.php inside your application/libraries directory and the my_form_validation_lang.php into your application/languages/english (or make your own validation language...).

After that, when you set the validation rule for your edited field you can use is_unique_except rule. In your particular case, assuming you have in your users table an id that uniquely identifies the row you want to edit, it would go on the lines of this:

PHP Code:
$this->form_validation->set_rules('user','Username','trim|required|is_unique_except[users.user.id.'.$id.']'

...where "users" is the table name, "user" is the field you want to edit, "id" is the name of the uniquely identifying column, and "$id" is the id of the row you want to edit.

You can of course delete the other form validation rules that are in there or even change the code and make it a callback rule. Hope this helped you.
Reply


Messages In This Thread
form validation behavior - by Edel - 11-25-2016, 09:04 PM
RE: form validation behavior - by InsiteFX - 11-26-2016, 05:58 AM
RE: form validation behavior - by Avenirer - 11-28-2016, 08:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB