acf_field_select::format_value_single
Method of the class: acf_field_select{}
No Hooks.
Returns
null. Nothing (null).
Usage
$acf_field_select = new acf_field_select(); $acf_field_select->format_value_single( $value, $post_id, $field );
- $value(required)
- .
- $post_id(required)
- .
- $field(required)
- .
acf_field_select::format_value_single() acf field select::format value single code ACF 6.0.4
function format_value_single( $value, $post_id, $field ) {
// bail early if is empty
if ( acf_is_empty( $value ) ) {
return $value;
}
// vars
$label = acf_maybe_get( $field['choices'], $value, $value );
// value
if ( $field['return_format'] == 'value' ) {
// do nothing
// label
} elseif ( $field['return_format'] == 'label' ) {
$value = $label;
// array
} elseif ( $field['return_format'] == 'array' ) {
$value = array(
'value' => $value,
'label' => $label,
);
}
// return
return $value;
}