@Log1x this looks awesome! I installed and I’m trying it out, but I can’t seem to get any output. I created a foreach loop that is pulling in partials based on acf_fc_layout (based on the recommendations of nathobson and jasonbaciulis):
@foreach ($components as $component)
@include('partials/builder/'.$component->acf_fc_layout)
@endforeach
Here are the contents of the partial, which is successfully loading, but not printing any of the field values:
Hey Brandom, I really appreciate your effort to help us write such cleaner and more maintainable code. Although there’s one big gotcha that took me hours to debug that I think you should warn people when using this technique. It took me a long time to figure out why the custom fields were not working in a production server but were working in my local mac environment, it turned out to be all about the letter case in the file and folder names.
As a quick example, if you create a file named Button.php and try to call get_field_partial('components.button') , it won’t work because it will look for a button.php (lower cased). Same thing for folder names such as Fields and fields .
I think that because all other files and folders around the app folder are all capitalized (since they are classes), I also happened to capitalized the custom fields. Big problem is that it didn’t care at all in my mac environment, but the moment I’ve uploaded it to the linux production server nothing worked hehe, taking some good hours to find out why and update everything.
I want to reuse fields on multiple options pages.
The catch is that options are basically all one page as far as ACF is concerned, so they need unique keys per options page.
I’m adding normal fields, not flexible content fields.
I tried both the ->addFields($header) method and the ->addFields(get_field_partial('partials.header')) method, and tried setting the ‘key’ on the FieldsBuilder and addFields.
With the above attempts, the same keys get used (can tell this quickly because the fields on new options pages are filled out already with text i entered through wp-admin on old options pages)
Is there a way to add a prefix to the key or change the key after doing addFields? I don’t see any mention in the ACFBuilder docs about prefixing a key. Or am I going about this the wrong way?
Thanks
Edit: This seems more of an ACFBuilder question so I submitted it on their repo. I’ll update here if a solution is found.
With the current implementation of ->addFields, I don’t see a sane way in ACF Builder’s source to pull this off for the entire field group; especially with the FieldsBuilder instance protecting $config and $fieldManager.
I can see this being useful if implemented though as shown in the issue you opened.
Hey, After following Brandon’s guide I am having an issue. I can create fields and they display in WordPress backend, however, the problem is with Media. No image is showing and the loading circle is swirling all the time.
I also notice that removing the code from the bottom of setup.php file helps (code below), but of course, it is necessary to use the builder.
Any ideas how to resolve this problem guys? Is any of you had this problem.
Not really sure why that is happening, but there’s either a PHP error which should be in your error log or a JS error which would be in devtools console. If so, can you share them?
I am trying to use this with using Lando as my development stack. Changing or amending the fields do not refresh at all. I have do lando restart every time I amend the files. The watch does detect changes and I checked the container. Do I miss something? Why cannot change the fields?
So i try to set only some page template like
$agency
->setLocation(‘page_template’, ‘==’, ‘…/…/…/resources/views/landing-agency.blade.php’);
and add some fields , but not work could you told me how to do this ?
it was views/landing-agency.blade.php’); now it work