public function rules(): array
{
return [
[
['id', 'parent_id'],
'integer',
],
[
'name',
'unique',
'targetAttribute' => ['name', 'parent_id'],
],
];
}
send post
name = lol
parent_id = fff
correct validate
"name": "Database Exception",
"message": "SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: \"ffff\"\nThe SQL being executed was: SELECT EXISTS(SELECT * FROM \"osm_region\" WHERE (\"osm_region\".\"name\"='lol') AND (\"osm_region\".\"parent_id\"='ffff'))",
| Q | A
| ---------------- | ---
| Yii version | 2.0.13
| PHP version | 7.1
| Operating system | ubuntu
Are you sure you do validate() and doesn't do save(false)?
You should use [['id', 'parent_id']', 'filter', 'filter' => 'intval'].
Thank you for your question.
In order for this issue tracker to be effective, it should only contain bug reports and feature requests.
We advise you to use our community driven resources:
If you are confident that there is a bug in the framework, feel free to provide information on how to reproduce it. This issue will be closed for now.
_This is an automated comment, triggered by adding the label question._
I have the same problem, how can I solve it?
FilterValidator didn't work for me
In my case the error occurs when I try to compare the column type integer with an empty string