Welcome Guest, Not a member yet? Register   Sign In
Set Rules in model.
#2

It might be better to create a new unique rule which allows you to check whether any value returned from the database with the same value shares the ID of the record being validated. Then you could use the built-in is_unique rule for inserts and use the new rule for updates. It's also likely that you will need the same functionality again in the future, so the extra time it might take to build (or find) a validation function that handles it properly will be worthwhile.

Bonfire has a form validation function named unique() which serves that purpose fairly well, though it requires the field name in the form to match the name in the database table for the ID. The function was originally adapted from this article: http://code.tutsplus.com/tutorials/6-cod...--net-8308
Reply


Messages In This Thread
Set Rules in model. - by miiikkeyyyy - 03-03-2015, 09:17 AM
RE: Set Rules in model. - by mwhitney - 03-03-2015, 01:48 PM
RE: Set Rules in model. - by spjonez - 03-03-2015, 05:06 PM
RE: Set Rules in model. - by tapan.thapa - 03-03-2015, 09:18 PM
RE: Set Rules in model. - by spjonez - 03-04-2015, 06:45 AM
RE: Set Rules in model. - by mwhitney - 03-04-2015, 01:16 PM
RE: Set Rules in model. - by cartalot - 03-06-2015, 05:05 PM



Theme © iAndrew 2016 - Forum software by © MyBB