Home › Forums › Add-ons › Flexible Content Field › add_row in a clone field
Hello, I’m having an issue trying to insert a row into a flexible content which is a cloned field in another flexible content layout.
In my database the field have the value field_60dd6f2f4890b_field_6075935dba60e and when I try to use
addrow(field_60dd6f2f4890b_field_6075935dba60e, ['acf_fc_layout' => component_name', ... ...], $field_id);
nothing seems to happen. The error seems to come from the field value, and I don’t really know why because it’s the same as the database when doing some tests manually.
I can’t really find any help on the docs about this feature.. Maybe I can get some advice here.
Thanks!
if you are finding a field with a value of “field_60dd6f2f4890b_field_6075935dba60e” then this is likely the field key reference and not the field value.
I cannot really tell by your description what your field setup is. Add row will not work with nested repeaters including flex fields. Can you give a better description of your field setup?
Sure, here’s how the setup looks like
The “content” is a flexible content field
The “aside-content” is a cloned field from an ACF group just made for clones.
Hey @hube2, do you have any news about this subject?
I’m back at it today and you didn’t answer the last comment, I’ll try to figure this out. Hope I’m not bothering you.
Thanks!
Found out the solution, after some digging, I’ve realized that I didn’t try using the add_sub_row function. Which solved my problem using the following code:
add_sub_row(array(self::content_field, $this->row, self::aside_content_field), [
'acf_fc_layout' => 'aside_image',
'aside_img_credit' => 'test',
'aside_img_image' => 196
], $this->post_id);
Thanks for the help and sorry for the double posts!
You must be logged in to reply to this topic.
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.