Welcome Guest, Not a member yet? Register   Sign In
is_unique issue on update
#5

(03-25-2021, 08:43 PM)InsiteFX Wrote: You would need to get the user record from the database first then compare the emails.

Build your data with or without email then update the users record.

If you already have the users id etc.; on login then you could store the email in the
session and check it there without the extra trip to the database.
I have a controller which updates data in 3 different models i.e. users controller updates data in both users, address and contacts tables. each validation rules are stored in their respective models but when i try to update, the validation rule fails at is_unique claiming duplicates email and phone number have been detected

Contacts model: code sample

PHP Code:
protected $validationRules      = [
        
'email' => 'permit_empty|valid_email|is_unique[contacts.email,id,{id}]',
        
'telephone' => 'permit_empty|is_unique[contacts.telephone,id,{id}]',
        
'mobile' => 'permit_empty|is_unique[contacts.mobile,id,{id}]',
        
'fax' => 'permit_empty|is_unique[contacts.fax,id,{id}]',
    ]; 

i tried to change the the validation placeholder. code sample below
PHP Code:
'email' => 'permit_empty|valid_email|is_unique[contacts.email,id,{users.id}]' 
But I am still getting the same error. 
Any insight on how I should proceed or an alternative approach is much appreciated.
Reply


Messages In This Thread
is_unique issue on update - by eleumas - 03-25-2021, 11:12 AM
RE: is_unique issue on update - by InsiteFX - 03-25-2021, 08:43 PM
RE: is_unique issue on update - by llyimo1920 - 04-20-2021, 10:47 PM
RE: is_unique issue on update - by Ahyaislive - 11-12-2021, 12:02 AM
RE: is_unique issue on update - by eleumas - 03-26-2021, 07:15 AM
RE: is_unique issue on update - by charleyskira - 12-16-2021, 08:30 AM
RE: is_unique issue on update - by kenjis - 12-16-2021, 09:48 PM
RE: is_unique issue on update - by BilltheCat - 01-20-2022, 03:00 AM
RE: is_unique issue on update - by Mano - 04-01-2022, 08:56 AM
RE: is_unique issue on update - by InsiteFX - 04-09-2022, 12:43 AM
RE: is_unique issue on update - by kenjis - 04-09-2022, 01:01 AM
RE: is_unique issue on update - by Mano - 04-10-2022, 03:04 AM
RE: is_unique issue on update - by ingrenee - 05-30-2022, 10:19 AM
RE: is_unique issue on update - by danger89 - 10-07-2022, 02:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB