Answer the question
In order to leave comments, you need to log in
How can I make the attribute populated but optional?
I'm trying to edit a model from a form.
There is an id field. If I specify it in the rules, then editing is fine, the model is filled from the post.
But at the same time, an error occurs during creation - it tries to write null in the id field, and it should be automatically filled in the database.
If I remove the id from the rules, it is created normally, but when editing it is not filled from the array.
Answer the question
In order to leave comments, you need to log in
In situations where it is worth filling in attributes in one case and not in the other, it is worth using scripts and safe attributes
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question