I've simplified my use case to Umbraco's default's for rendering pages and blocklists. I've created a block called Fruit that has one field: a dropdown with the following options:
""
Orange
Banana
Pear
My code for rendering the Fruit block - and the one single field the block contains is:
So the idea is that all Fruit blocks - if they are left without a value in that dropdown field will be "Apple". If I add one Fruit block to the page without a value indicated in the dropdown: I get an apple. If I copy that Fruit block or independently add another Fruit block without a fruit indicated both the first Fruit block and the second fruit block render "".
Suddenly the fallback code to render "Apple" instead of "" does not function because there's a second consecutive block on the page that makes use of the fallback?
Here's a link to a screen capture of me experiencing the issue. I find it's a little blurry if you play over Google Drive but crisp if you were to download it. Maybe either way: it sets the stage.
I could certainly use a different way to render "Apple". I could make the field mandatory and add "Apple" as the first selectable option. I know there are some plugins out there to build upon Umbraco's dropdowns re: default values - and maybe this is why? But I'm trying to keep this project lean and the CMS experience of no selection = "Apple" is what I'd like to be able to go with.
Set fallback for dropdown
I've simplified my use case to Umbraco's default's for rendering pages and blocklists. I've created a block called Fruit that has one field: a dropdown with the following options:
"" Orange Banana Pear
My code for rendering the Fruit block - and the one single field the block contains is:
So the idea is that all Fruit blocks - if they are left without a value in that dropdown field will be "Apple". If I add one Fruit block to the page without a value indicated in the dropdown: I get an apple. If I copy that Fruit block or independently add another Fruit block without a fruit indicated both the first Fruit block and the second fruit block render "".
Suddenly the fallback code to render "Apple" instead of "" does not function because there's a second consecutive block on the page that makes use of the fallback?
Here's a link to a screen capture of me experiencing the issue. I find it's a little blurry if you play over Google Drive but crisp if you were to download it. Maybe either way: it sets the stage.
https://drive.google.com/file/d/1j3zGF4TdCNhVxxfRAF2IelI1zfSoXrq7/view?usp=sharing
I could certainly use a different way to render "Apple". I could make the field mandatory and add "Apple" as the first selectable option. I know there are some plugins out there to build upon Umbraco's dropdowns re: default values - and maybe this is why? But I'm trying to keep this project lean and the CMS experience of no selection = "Apple" is what I'd like to be able to go with.
is working on a reply...