I found the way to fix the file field: The form html in the bootstrap modal is set from an Ajax request. At acf_form() I found the hint, that acf.do_action('append', $('#popup-id')); must be called after an Ajax request.
With this function call in the event-listener shown.bs.modal deleting/replacing of the file works.
I have to correct myself. When I write link field, I mean the ACF file field. The information entered for this field is used for a download link, so I mistakenly called it Link field.
Hello John
Thank you very much for the explanations and tips, that helps me a lot. I now need to think about which option is best for me to implement.
Hello John
Many thanks for the advice. I have corrected the spelling mistake in is_search.
The explanation regarding the sorting explains exactly what I see in the output of the search results after sorting by date.
What I still don’t understand is that the sorting works when querying the two cpts on an overview page (first code section) but not in the search.
Can I rewrite the search query so that sorting by date works or would ACF fields have to be named the same in order to enable sorting with $query->set('orderby', 'meta_value'); $query->set('meta_key', 'date_field_name');?
Thank you for the pointers. I will take a close look at the function on github.
At the moment I have added another field to the field group. This field is assigned a default value and is set to read-only.
When saving duplicated rows, the default value of the field is passed on and I can check this in the loop. It’s not a very nice solution but it seems to work.
Before that I used your function add_filter('acf/validate_value/name='.$field_name,... to declare a field as unique. So there will always be one field unique that can be checked in the loop.
Maybe there is a more elegant solution?
Hello John
Thank you very much for the advice. The setting described is really very similar and the procedure described has brought me further.
After thinking about it for a while over the weekend, I decided to stick with the ID field. I restarted from scratch and I could fix the problem when deleting a Row and passing the ID field (the ReadOnly code was not commented everywhere…).
Now I stumble upon another problem. When a Row is duplicated, all values are duplicated (including the ID). So in the repeater loop an ID can appear multiple times and that makes checking what is new/edited/remained the same complicated.
I thought that the ID field can be defined as unique according to your post (https://tinyurl.com/2dqajbcf). Or is there a way to give the Duplicate button a custom JS function to empty the input field?
Thanks for the help.
I understand that well. It is certainly very difficult to understand my approach and the chosen process with my description. I will rethink everything and try again.
Thank you for your time and advice.
I tested with priority 5 and 20 and it made no difference.
I used the hook acf/validate_save_post to output $_POST in the console. Then I saved a the master again with a new child. But I can’t see a kurs_id field in the output.
Then I did the same but gave the kurs_id field a default value of 0. Now I can see a the field in the $_POST with the default value. But in the end, this did not solve the problem either.
No, first it was set to read-only using ‘acf/load_field/name=kurs_id’ hook and $field['disabled'] = 1;. But this code is currently commented.
Hi
Yes, it is a repeater subfield created with ACF (). My setup is: WordPress 6.2 with roots/sage9, PHP 8.0.28 and the Plugin ACF Pro 6.1.5.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.