Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

af_get_field not working with sub fields inside "Group" field #35

Closed
tyrann0us opened this issue Jun 12, 2018 · 3 comments
Closed

af_get_field not working with sub fields inside "Group" field #35

tyrann0us opened this issue Jun 12, 2018 · 3 comments

Comments

@tyrann0us
Copy link
Contributor

tyrann0us commented Jun 12, 2018

Hi @fabianlindfors, thank you for this great plugin!

I noticed that af_get_field won't work if the field type is set to "Group". Example: Field of type "Group" called "field" has a sub field called "sub_field". How am I supposed to access the sub field? af_get_field( 'field[sub_field]' ) does not work, neither does af_get_field( 'sub_field' ).

// Also search sub fields if field is clone
if ( 'clone' == $field['type'] && isset( $field['sub_fields'] ) ) {

If I change the condition to if ( isset( $field['sub_fields'] ) ) { then af_get_field( 'sub_field) works.

Would it be safe to change the condition as mentioned? Thanks!

@fabianlindfors
Copy link
Collaborator

I think that would work! I implemented your suggested changes with commit e30e128.

Thanks a lot!

@cedricDevWP
Copy link

Hi,

I think there is a problem when you have a group that owns another group.

Example :

1 ACF :
image

who has a acf dog (see 2 ACF)

2 ACF :
image

Who has a acf owner (see 3 ACF)

3 ACF :
image

If i do :

af_get_field("civilite") => Return false

When i see the data :
image

We do not go through the group

@cedricDevWP
Copy link

cedricDevWP commented Nov 13, 2019

to correct I add:

if ( $sub_field_name == $field_key_or_name ) { return $sub_field_value; }elseif( $sub_field_name == 'groupe'){ foreach ($sub_field_value as $sub_field_name_2 => $sub_field_value_2) { if ( $sub_field_name_2 == $field_key_or_name ) { return $sub_field_value_2; } } }

image

for the future it would not be judicious to use the indentifiants and not the names like key?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants