Default value/Initial state for the Toggle datatype is not working.
I have a datatype Toggle (CardView in the attached picture) with the initial value selected as true.
When using this datatype in an existing document type from a block list, I have to go to every node where that component is present, click on submit button, and click on save and publish. Then only we can see the default value of the datatype as true.
It's a long time Umbraco pain.... essentially in the DataType, that defines a toggle, the 'initial value' is only controlling the state of the editor when it is loaded in the backoffice for the first time.
If the page hasn't been loaded for editing in the backoffice, the the property has no value at all :-(
which is a pain if you've just added it to an existing Document Type!!
The low tech trick is try and phrase your questions for toggles, so that the 'absence' of the value represents the default outcome you'd prefer.
So if you were controlling whether a page should appear on a Menu - and by default you wanted things to appear, you'd call the toggle - 'Hide from Menu' - so the absence of a value in code would mean the page was part of the navigation - but if by default you wanted pages not to appear in navigation you'd call the toggle 'Show in menu', so the absence of a value in code would mean don't show it...
So in your screenshot, call it 'Show Table View' instead of 'Card View' and have description (By default Card View is used) - nobody then needs to select anything for the default outcome, and if they want to switch it, they only have to edit that particular one...
Default value/Initial state for the Toggle datatype is not working.
I have a datatype Toggle (CardView in the attached picture) with the initial value selected as true.
When using this datatype in an existing document type from a block list, I have to go to every node where that component is present, click on submit button, and click on save and publish. Then only we can see the default value of the datatype as true.
Publish with descendants also does not work.
Please suggest any approach to solve this.
Umbraco version: 8.18.8
Hi Sunil
It's a long time Umbraco pain.... essentially in the DataType, that defines a toggle, the 'initial value' is only controlling the state of the editor when it is loaded in the backoffice for the first time.
If the page hasn't been loaded for editing in the backoffice, the the property has no value at all :-(
which is a pain if you've just added it to an existing Document Type!!
The low tech trick is try and phrase your questions for toggles, so that the 'absence' of the value represents the default outcome you'd prefer.
So if you were controlling whether a page should appear on a Menu - and by default you wanted things to appear, you'd call the toggle - 'Hide from Menu' - so the absence of a value in code would mean the page was part of the navigation - but if by default you wanted pages not to appear in navigation you'd call the toggle 'Show in menu', so the absence of a value in code would mean don't show it...
So in your screenshot, call it 'Show Table View' instead of 'Card View' and have description (By default Card View is used) - nobody then needs to select anything for the default outcome, and if they want to switch it, they only have to edit that particular one...
regards
marc
is working on a reply...