Skip to content

Commit c2f6ab9

Browse files
committed
- check if the value is being passed down with the' __key' or the 'key' to better compensate for clone fields, specifically when groups are cloned
1 parent 5d500c0 commit c2f6ab9

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/FieldConfig.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,17 @@ public function resolve_field( $root, array $args, AppContext $context, ResolveI
390390

391391
// If the root being passed down already has a value
392392
// for the field key, let's use it to resolve
393-
if ( ! empty( $root[ $field_key ] ) ) {
394-
return $this->prepare_acf_field_value( $root[ $field_key ], $node, $node_id, $field_config );
393+
if ( isset( $field_config['key'] ) && ! empty( $root[ $field_config['key'] ] ) ) {
394+
return $this->prepare_acf_field_value( $root[ $field_config['key'] ], $node, $node_id, $field_config );
395395
}
396396

397-
if ( ! empty( $root[ $field_config['name'] ] ) ) {
397+
// Check if the cloned field key is being used to pass values down
398+
if ( isset( $field_config['__key'] ) && ! empty( $root[ $field_config['__key'] ] ) ) {
399+
return $this->prepare_acf_field_value( $root[ $field_config['__key'] ], $node, $node_id, $field_config );
400+
}
401+
402+
// Else check if the values are being passed down via the name
403+
if ( isset( $field_config['name'] ) && ! empty( $root[ $field_config['name'] ] ) ) {
398404
return $this->prepare_acf_field_value( $root[ $field_config['name'] ], $node, $node_id, $field_config );
399405
}
400406

0 commit comments

Comments
 (0)