You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
readOnly attribute not working on Autocomplete field #177
Hey @dtannen sorry for the delay I took a little vacation.
Since this PR https://github.com/64robots/nova-fields/pull/167/files we are not redeclaring readOnly anymore so if you use the modifier as described in Nova Docs should work. Can you try and let me know if it works? If not, please, provide reproduction steps and I will try to fix it.
Thanks!
@beliolfa It seems like you are still referencing your readOnly attribute inside your vue components, which itself is looking at this.field.readOnly. Meanwhile Nova has its on computed property for that called isReadonly, in which readonly (see the lowercase o) but also this.field.extraAttributes.readonly are looked at, the latter is the property which is set by Nova-fields.
This results in the behaviour that your fields are not displaying as readonly, but behave that way (value does not get saved).
Additionally, the JSON field will save values even when a field inside it has been marked as readonly, as a workaround for our project I extended your JSON-class and changed fillAttributeFromRequest, so that the fields that are readonly get rejected before filling (via ->reject->isReadOnly($request)).
Reacted by Philipp Kübler, Simon Hansen and Sebastian Müller
Hey @NeroAzure thank you for your detailed solution. It looks like you fixed the issue in your projects. Do you mind opening a PR so I can take a look? If you are busy I will fix it as soon as I can.
Activity
beliolfa commentedon Jul 27, 2020
Hey @dtannen sorry for the delay I took a little vacation.
Since this PR https://github.com/64robots/nova-fields/pull/167/files we are not redeclaring
readOnlyanymore so if you use the modifier as described in Nova Docs should work. Can you try and let me know if it works? If not, please, provide reproduction steps and I will try to fix it.Thanks!
NeroAzure commentedon Feb 1, 2021
@beliolfa It seems like you are still referencing your
readOnlyattribute inside your vue components, which itself is looking atthis.field.readOnly. Meanwhile Nova has its on computed property for that calledisReadonly, in whichreadonly(see the lowercaseo) but alsothis.field.extraAttributes.readonlyare looked at, the latter is the property which is set by Nova-fields.This results in the behaviour that your fields are not displaying as readonly, but behave that way (value does not get saved).
Additionally, the JSON field will save values even when a field inside it has been marked as readonly, as a workaround for our project I extended your JSON-class and changed
fillAttributeFromRequest, so that the fields that are readonly get rejected before filling (via->reject->isReadOnly($request)).beliolfa commentedon Feb 15, 2021
Hey @NeroAzure thank you for your detailed solution. It looks like you fixed the issue in your projects. Do you mind opening a PR so I can take a look? If you are busy I will fix it as soon as I can.