Skip to content

Commit fe4a164

Browse files
Mr2Ppriethor
andauthored
Get the formatted_value from the original field value (#211)
* Get the `formatted_value` from the original field value not the formatted value for rest The `formatted_value` property of the $field['name'] . '_source' should come from the original value, not the REST value. Other plugins might change the REST value using the filter `acf/rest/format_value_for_rest`, which can cause the `formatted_value` to be incorrect. * Get the formatted_value from the original field value The formatted_value property of the $field['name'] . '_source' should come from the original value, not the REST value. Other plugins might change the REST value using the filter acf/rest/format_value_for_rest, which can cause the formatted_value to be incorrect. * Lint ternary operator --------- Co-authored-by: priethor <[email protected]>
1 parent b39c8b5 commit fe4a164

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

includes/rest-api/class-acf-rest-api.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ public function load_fields( $object, $field_name, $request, $object_sub_type )
231231
}
232232

233233
// Format the field value according to the request params.
234-
$format = $request->get_param( 'acf_format' ) ?: acf_get_setting( 'rest_api_format' );
235-
$value = acf_format_value_for_rest( $value, $post_id, $field, $format );
234+
$format = $request->get_param( 'acf_format' ) ? $request->get_param( 'acf_format' ) : acf_get_setting( 'rest_api_format' );
235+
$rest_value = acf_format_value_for_rest( $value, $post_id, $field, $format );
236236

237237
// We keep this one for backward compatibility with existing code that expects the field value to be.
238-
$fields[ $field['name'] ] = $value;
238+
$fields[ $field['name'] ] = $rest_value;
239239
$fields[ $field['name'] . '_source' ] = array(
240240
'label' => $field['label'],
241241
'type' => $field['type'],

0 commit comments

Comments
 (0)