Umbraco 14 Custom Property Editors save property v...
# help-with-umbraco
j
Hi all, I am creating a property editor in Umbraco 14 and I am confused about the relationship between the property editors and the rest of the backoffice. In my current case I am allowing the user to select a list of toggles from true/false and am trying to achieve a proof of concept with only one. I have set this boolean variable to be a public property of the class, the state changes fine when I toggle the switch however, when the model is saved then the state is reset, i.e the state of the boolean will always go back to false. Just to clarify I DO have the change triggering an event that sends an 'UmbPropertyValueChangeEvent' using the @click event. How do I get the state of this toggle to be saved when the editor saves the state of the model? Just to clarify the toggle variable is set like this @property({type: Boolean}) public checked = false; I have tried with a constructor setting the value and still I cannot save the state between refreshes. Thank you
l
When the
UmbPropertyValueChangeEvent
event is triggered, the property will take the
value
from the property-editor, (then bubble it up, to the workspace, or wherever it's being used).
Copy code
this.value = yourValue; // e.g. whatever the value you want to save
this.dispatchEvent(new UmbPropertyValueChangeEvent());
Setting the
this.checked
on your property-editor wont save anywhere, it's only used as state within the component itself. Hope this helps.
j
Thank you for the reply! Just to clarify I do have the UmbPropertyValueChangeEvent triggering after the value has changed. I think the issue may be more to do with the propertyEditorSchemaAlias or how Umbraco is parsing the value as it's appearing in HTML as "False" but not changing regardless of what I try
14 Views