Home Forums General Issues Select default value


Select default value

  • I’m struggling with displaying a default value from a select box.

    I have a series of custom fields which are displayed in the User Profile page. One of them is a select box which contains a list of UK counties. I am trying to get it to work by starting the values with ‘- Select -‘. I did this by making the field required (which it has to be), entering value/label pairs e.g.

    Aberdeenshire : Aberdeenshire
    Anglesey : Anglesey
    Angus (Forfarshire) : Angus (Forfarshire)
    Antrim : Antrim

    Leaving the default value empty, setting Allow Null to yes, multiple value to no, conditional logic to no. This doesn’t work. When I look at it on the users profile page, ‘Aberdeenshire’ is still the displayed value. I’ve also tried by putting ‘null’ in the default value but this doesn’t work either.

  • It doesn’t work the way you’re trying to use it.

    The choices field does not allow you to enter a empty value.

    When you set Allow null to No ACF does not add a - Select - item so that a value is always selected. You can set the default if you don’t want the first one selected.

    When you set Allow null to Yes ACF does add a - Select - item so that the user does not need to select a value.

    There have been some discussions in the past here about using an acf/load_field filter to alter the selections to include a null/empty value when a field is required, but I’ve been looking for it and could not find it. You could try that, see

  • Hi John,

    Thanks for your guidance 🙂

    Just so I understand you correctly, here’s a screenshot of my settings when creating the Custom Field:

    And here’s a screenshot of how it appears to the user:

    As you can see, -Select- is added, but it still gets ignored in favour of the first actually entry (Aberdeenshire). If I switch to this: (with allow null now set to ‘No’. Then the user gets this with no -Select-

    With the first case I inspected the select box element and saw this:

    As you can see the -Select- option is ignored and ‘Aberdeenshire’ is selected like so: <option value="Aberdeenshire" selected="selected">Aberdeenshire</option>

    I should also note I have tried both of those set ups above with a default value of null as here:

    And also -Select – as here:

    Is this what you’d expect to see based on your explanation above?



  • I’m not sure if this is a bug or not. To be honest, I’ve just used the ACF fields the way they work and haven’t really noticed this.

    So I have another suggestion.

    Create an choices list that looks something like

    none : -- SELECT --
    Aberdeenshire : Aberdeenshire
    Anglesey : Anglesey

    Set it allow null to no
    set the default value as none
    then create a custom validation filter that returns ‘Please Select a County’ if the value is ‘none’

  • Hi John,

    Thanks again for your input 🙂

    It looks like I might’ve solved the mystery!

    Just on a hunch I created a brand new user and then logged in as them. It worked just fine. So the only reason it didn’t seem to be working was because it *was* acting correctly – e.g. an existing user had probably already chosen a county.

    But thank you – at the very least because of your help I’ve discovered other things I can do with ACF!


Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Select default value’ is closed to new replies.