Hello;
In my table Nomenclatures, the column “hos” can be null, but must be unique.
Thus I add a rule in NomenclaturesTable.php :
public function buildRules(RulesChecker $rules): RulesChecker
{
$rules->add($rules->isUnique(
['hos'],
['allowMultipleNulls'=>true]
));
return $rules;
}
This option is documented here.
But it does not work as expected : by sending the field with no value, I get the field with a red border and the message “1”. By replacing [‘allowMultipleNulls’=>true] by [‘allowMultipleNulls’=>“TOTO”] for example, I get the error message “TOTO”.
This option runs as a message !
Even stranger…
In the documentation, in the Creating re-usable rules chapter, a class IsUniqueWithNulls is referenced.
I don’t find any documentation about this class, and the example does not work in my code !
What is the solution ?
Thanks.