Subject: How do validate a single model attribute?
How do I validate only a single attribute?
Using the model and validations how do I validate $client_id before passing to Customer::find()?
Because if $client_id = '1_1' will retry customer with id of 1 if exist.
I could do if(strcmp($customer->id, $client_id) != 0) after Customer::find(), however because I already have validations in model why not use it.
Controller client:
1publicfunctiondelete($client_id)
2 {
3//code 4 5// Find by primary key 6// WARNING: Does Type Juggling & Trucking for converting string to int! 7$customer = Customer::find($client_id);
8 9//code10 }
Model:
1classCustomerextendsActiveRecord\Model2 {
3// Code for validates4 }
Subject: How do validate a single model attribute?
How do I validate only a single attribute?
Using the model and validations how do I validate $client_id before passing to Customer::find()?
Because if $client_id = '1_1' will retry customer with id of 1 if exist.
I could do if(strcmp($customer->id, $client_id) != 0) after Customer::find(), however because I already have validations in model why not use it.
Controller client:
Model: