Hi, i have a little problem with rules on Yii2, it give me a false positive when try to verify on save to DB if some information (cuenta) exist in other field of DB (subcuenta).
I use this rule to verify
public function rules()
{
return [
...
[['tipocuenta_id', 'user_id', 'cuenta'], 'required'],
[['cuenta', 'subcuenta'], 'string', 'max' => 100],
['subcuenta', 'default'],
[['tipocuenta_id', 'cuenta'], 'unique', 'targetAttribute'=> ['tipocuenta_id', 'subcuenta'], 'message' => 'This Account exist as subcuenta'],
...
];
}
This is the information that i have in DB
mysql> select cuentasid, cuenta, subcuenta from cuentas where cuenta like '%TEMP%';
+-----------+------------------+-----------------------+
| cuentasid | cuenta | subcuenta |
+-----------+------------------+-----------------------+
| 9254 | TEMP | TEMP SUBCUENTA |
+-----------+------------------+-----------------------+
1 row in set (0.00 sec)
mysql> select cuentasid, cuenta, subcuenta from cuentas where subcuenta like '%TEMP%';
Empty set (0.00 sec)
I do not know why when i try to save “TEMP” in cuenta and empty value on subcuenta it show the error ‘This Account exist as subcuenta’ if i don’t have in subcuenta the value “TEMP”, i’m using Yii 2.0.11.2 hope you can help
Warm Regards