Current status: Solved. . Done
Allow Null on Colour Picker?
  • I'm using the colour picker to control the primary and background colour of posts on a site (don't ask!). Anyway, I'd like to set up some defaults in the CSS that are overwritten with whatever is chosen with the colour picker.

    Problem is, the colour picker itself defaults to #FFF if nothing is chosen, which means we end up with white text on a white background if nothing is chosen.

    Allow Null doesn't seem to be an option at the moment. Is this something that could be built-in in the future, or is there something I can do that lets me use a different colour if #FFF is chosen?

    e.g.
    <?php $colour = get_field('colour');
    if ¢color == "#FFFFFF" { ?>
     
    <style type="text/css">
    .element { color: #444444; }
    </style>
     
    <?php } ?>


    I've not tested the above, but as I wrote it on the fly I am 100% sure it wouldn't work! Allow Null would still be preferential so that you could use a Conditional –
    <?php if(get_field('colour')) { ?>
    ...
    <?php } ?>


    Thanks,
    Jamblo