acf_field_select::format_value_single
Formats the value when the select is not a multi-select.
Метод класса: acf_field_select{}
Хуков нет.
Возвращает
Разное.
Использование
$acf_field_select = new acf_field_select(); $acf_field_select->format_value_single( $value, $post_id, $field );
- $value(разное) (обязательный)
- The value to format.
- $post_id(int|строка) (обязательный)
- The post_id from which the value was loaded.
- $field(массив) (обязательный)
- The field array holding all the field options.
Список изменений
| С версии 3.6 | Введена. |
Код acf_field_select::format_value_single() acf field select::format value single ACF 6.4.2
public function format_value_single( $value, $post_id, $field ) {
// Bail early if is empty.
if ( acf_is_empty( $value ) ) {
return $value;
}
$label = acf_maybe_get( $field['choices'], $value, $value );
if ( $field['return_format'] === 'label' ) {
$value = $label;
} elseif ( $field['return_format'] === 'array' ) {
$value = array(
'value' => $value,
'label' => $label,
);
}
return $value;
}