vinkla / extended-acf

Register advanced custom fields with object-oriented PHP
MIT License
445 stars 61 forks source link

Bad return on the call of a repeater generate #68

Closed AlexVWeb closed 4 years ago

AlexVWeb commented 4 years ago

Predictable behavior

I should have a table with my different fields included in my repeater.

Actual behavior

I get the number of elements to create when I dump: dump ($match, get_field ('site', $match-> ID)); I take back " 1 "

instead of retrieving with the same fields generate in the ACF administration: 0 => [ "url" => [ "title" => "Home" "url" => "// localhost: 3000 /" "target" => "" ] "logo" => [] ]

Steps to reproduce the problem

I can't reproduce the bug

Versions

- WordPlate: ^ 8.4
- PHP: ^ 7.3
vinkla commented 4 years ago

Please make your issue more informative. I don't understand your problem.

Also, try registering your fields with the UI and see if that works first.

AlexVWeb commented 4 years ago

With the code below, I want to recover the "Sport" taxonomy in "Object" format, the problem is that I receive at the output only the ID, while the same form done with the administration of ACF works.

register_extended_field_group([
    'title' => 'Sport',
    'location' => [
        Location::if('taxonomy', 'championship')
    ],
    'fields' => [
        Taxonomy::make('Sport', 'sport')
            ->returnFormat('object')
            ->taxonomy('sport')
            ->loadTerms()
            ->saveTerms()
            ->createTerms()
            ->appearance('select'),
    ],
    'menu_order' => 0,
    'position' => 'normal',
    'style' => 'default',
    'label_placement' => 'top',
    'instruction_placement' => 'label',
    'hide_on_screen' => PARAMS['hide_all_screen'],
    'description' => '',
]);
dump(get_field('sport', $match['championship']));

I get the ID: image When I should get a WP_Term: image

I have the same problem with several other "Fields", but on another project everything worked fine!

(Translated from French)

vinkla commented 4 years ago

Does it work if you register your fields with the UI instead of this package?

AlexVWeb commented 4 years ago

Does it work if you register your fields with the UI instead of this package?

Yes it works very well with the UI interface, this problem also happens to me with the Repeaters, when I do a

get_field('repeater', $ post_id)

on a Repeater Wordplate it returns the ID, whereas with the UI interface it returns the content of the elements of my repeater

vinkla commented 4 years ago

Okay, then it could be an issue with this package. Have you looked into the source code and see if you could find the issue?

vinkla commented 4 years ago

What is the output of following code in your project? We need to confirm that we get the correct field data.

$field = Taxonomy::make('Sport', 'sport')
  ->returnFormat('object')
  ->taxonomy('sport')
  ->loadTerms()
  ->saveTerms()
  ->createTerms()
  ->appearance('select');

dump($field->toArray());
vinkla commented 4 years ago

Just tried this locally and it seems to work if you remove loadTerms.