Home Forums General Issues Variable for select choices? Reply To: Variable for select choices?

  • Short answer: not really, no.

    Long answer:

    Option 1:
    You would probably also need to have them input a label for the custom choice. You could create both an acf/load_value and an acf/prepare_field filter. In the acf/load_value filter you would set the field value of custom to the value of the image field. In the acf/prepare_field filter you would include the new value as one of the choices. Both would be required to ensure that the value is set and remains selected. You would also need to keep the “custom” value so that they could change it.

    Option 2:
    Create an acf/load_value field for the select field. In this filter check the value and then return the image url from the image field if set to custom.

    Option 3:
    use the function acf_update_field() which is not documented, to permanently change the selections of the field. This will only work if you are not using acf-json. Basically you create an acf/save_post filter. In this filter you use get_field_object() to get the field and you update the choices then call acf_update_field() with the changed field object. It is also possible at this point it would probably also be possible to force the re-saving of a json file but at the moment I’m writing this I don’t know what function would be used or how to call it.

    The only reason I would do one of these is if you cannot do this by simply editing the PHP template.