Manage fields settings from the field’s UI. Settings can be set depending on the current screen location. In order to enable the Advanced Settings UI, you must enable the Field Group: Advanced Settings feature.
Choose the location screen where the settings should be applied. You can set multiple settings groups based on different locations.
Everywhere |
Administration |
Front-end |
The UI comes with predefined settings that can be used out of the box.
Setting name | Expected Value |
Required | True/False |
Hide field | True/False |
Hide label | True/False |
Default value | Text |
Placeholder | Text |
Instructions | Text |
Custom setting | True/False/Text |
Using the “Custom setting” option, you can set any valid field settings. Settings names can be found using acf_get_field()
. Usage example:
$select = acf_get_field('my_select_field'); // Using name
$select = acf_get_field('field_5f35690c1da04'); // Using key
/*
* Array
* (
* ...
* [placeholder] =>
* [instructions] => Vivamus magna justo, lacinia eget.
* [required] => 0
* [conditional_logic] => 0
* [wrapper] => Array
* (
* [width] =>
* [class] =>
* [id] =>
* )
* [choices] => Array
* (
* [choice_1] => Choice 1
* [choice_2] => Choice 2
* [choice_3] => Choice 3
* [choice_4] => Choice 4
* )
* [default_value] =>
* [allow_null] => 0
* [multiple] => 0
* [ui] => 0
* [ajax] => 0
* [return_format] => value
* ...
* )
*/
In this example, the Select field has the following settings: allow_null
, multiple
, ui
, ajax
, return_format
etc…
It is possible to alter field settings based on the screen location programmatically using the acfe/load_field
hook combined with acfe_is_admin()
and acfe_is_front()
functions.
Note that this method doesn’t require to enable the “Advanced Settings” in the field group as it is directly executed in PHP. Usage example:
add_filter('acfe/load_field/name=my_field', 'my_acfe_load_my_field');
function my_acfe_load_my_field($field){
// admin only
if(acfe_is_admin()){
$field['required'] = true;
}
// front-end only
if(acfe_is_front()){
$field['multiple'] = true;
}
// return
return $field;
}