Skip to content
This repository was archived by the owner on Jun 28, 2023. It is now read-only.

Pre filling select options

Koen edited this page Aug 1, 2019 · 4 revisions

Sometimes you want to have programmatic control over which options a user can choose in an ACF dropdown. To do so:

  • Go to Grrr\Acf\SelectPrefiller
  • Add a hook for a specific field name
  • Add the options needed to load for that field name

Reasons & scenarios

The most common reasons to do this are:

  • The values or labels for the options are generated programmatically
  • The values and labels for the options are reused across multiple groups

Example scenarios where this applies are:

  • Allowing the user to select a few global colours used in the front-end
  • Allowing the user to select an asset, like video or icon

See also:

Clone this wiki locally