CodeIgniter Forums
Request: Updated version of Form_validation::is_unique() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29)
+--- Thread: Request: Updated version of Form_validation::is_unique() (/showthread.php?tid=62893)



Request: Updated version of Form_validation::is_unique() - jLinux - 09-05-2015

The is_unique() form validation works great if you're creating a new record of whatever, but I ran into a small issue while editing a record.

Lets say you're editing a person and want to the is_unique() on the SSN, the issue I ran into, is the SSN is already going to be there for the user you are editing, so it may be a good idea to allow the user to specify the current value in a format something like table.column:value, then you can use some php and mysql to either ignore that value, or whatever you find suitable.

I know you can just add a new validation check, or edit an existing one, which is what I did here, but I just thought this might be a good feature for CI4

Or.. is there already a feature for this that I totally skipped over, and no one pointed out in the thread I referenced?


RE: Request: Updated version of Form_validation::is_unique() - jLinux - 09-05-2015

P.S. I can see how there may be some issues with this, seeing as how the "current" value may hold values that would throw the sscanf or a preg_match off, but theres gotta be some way to do it.


RE: Request: Updated version of Form_validation::is_unique() - Diederik - 09-05-2015

I have adopted the "unique" validation rule from Bonfire into my project. You can check it out here: https://github.com/ci-bonfire/Bonfire/blob/develop/bonfire/libraries/BF_Form_validation.php