I’m setting background colour using color palette but the issue I’m having is that is causes an error when the key value isn’t selected in the panel - I thought this should be combated by “<?php if($page->palette()->isNotEmpty()): ?>” or setting the blueprint default but neither fix the error
What sort of field is that? A select field? If so, using yaml doesn’t make sense. You are trying to convert this field to an array using yaml, but there is no index “key”.
On a side note: It’s not a good idea to put all this php code into the data-theme attribute. Store the result of your code in a variable, then echo that out into the attribute: