Custom Validation Rules in request
Good afternoon! I'm trying to apply my rules in request, but he doesn't see them. Just saves.
12 Replies
Hey @User142 I will take a look at this
This seems to work. Not sure if there's a difference with what you are doing.
Except that I did not use the invokableRule
@Harings Rob Can i ask you? What if you refresh the page and immediately click save? Are you saving successfully?
If I click on the field then the check will work.
I cannot see that video. But after refresh, when clicking save, it does validate.
@Harings Rob Is it possible to poll the field to change it to a WYSIWYG editor? Will your validation also throw an error that the field is empty?
I can do whatever I want in this rule, even if the field is a wysiwyg
By the way, thanks for the replies. But some strange behavior in the fields.
If I refresh the page and try to save it, it remains calm (I connected xdebug and it does not capture data as if the rule is being ignored). If I try to write something and then erase everything, then only then my rule is applied, as if the field does not see.
I did the validation like this
public function rulesForCreate(): array
{
return $this->rulesForTranslatedFields([], [
'city' => ['required', new RequiredWysiwyg],
]);
}
public function rulesForUpdate(): array
{
return $this->rulesForTranslatedFields([], [
'city' => ['required', new RequiredWysiwyg],
]);
}
And now, in any case, if the field is empty, then an error occurs.Hey @User142 I have checked again, created a new content, and saved without touching the wysiwyg field and my rule validates. Maybe I am not understanding what you are saying?