Open Norgul opened 3 months ago
I found what is the issue (though this still might be a bug).
In dependsOn()
this part is causing the issue:
if (!$product) {
$field->readonly();
return;
}
Even if I later set it as $field->readonly(false)
it doesn't work. To solve it, I needed to remove that part so that I have this:
if (!$product) {
return;
}
Is this normal behavior?
Hi @Norgul 👋
Thanks for reaching out to us.
What you describe here is expected behavior, inputs for fields marked as readonly
are discarded in the backend for safety reasons.
I am unsure what you are trying to achieve here, if you need some more directions in settings things up please describe your goal and I'll do my best 👌
@jeremynikolic thanks for the answer.
I know readonly
fields are discarded. What I think is a bug there though is the fact that even after I canceled readonly
status for a field with $field->readonly(false)
, it would still treat it as such.
Ah got you ! My bad, I missed that extra disabling readonly
step 👍
I believe you are right, updating the readonly after initial setup may not be picked up.
I'll look into it 🕵️
@Norgul I've been investigating this and the readonly change is actually well received and accounted for on the frontend 🤔
Something to check on your side, the screenshot you provided indicates your unit_id
is not nullable therefore the form failing when not having value for it therefore your schema most likely needs adjusting
Looking at the code samples I am wondering if the models/resources setup may be the cause here. To go further, please provide a sample reproducing repository 🙏
Not sure really. As you can see from payload submitted to the API, unit_id
does get forwarded. So I assume once the request is submitted and gets to the controller, Nova discards the field. I will see if I catch anything else. Thanks
Description:
Not sure if this is a bug or I implemented something wrong. I have a pivot table with additional FK (
unit_id
). If I useSelect
infields()
method pointing to that additional FK, saving the relation will fail even thoughunit_id
is present in the payload in the failing request.If however I replace
Select
with a hardcodedText
orNumber
field, it will have the same payload, but will go through.