Home Forums Backend Issues (wp-admin) acf_form + flexible content


acf_form + flexible content

  • I use flexible content with several layouts. I want to update the three fields of a layout. In my page.php, I use this code :

                $settings = array(
                    'post_id' => $post->ID,
                    'field_groups' => array(137),
                    'fields' => array('field_5a7dbf2864ced','field_5a7dbfdf64cef','field_5a7dc00c64cf0'),

    My form is displayed in frontend. If I add datas in this form in front and submit, the page is reloaded and the datas are in the fields of y form. All seems ok. But in my admin area, the content of each field is not good. The datas were not saved in the backoffice. Why ? Is there a way to update a layout flexible content from a form in front ?

  • Because the way that you are including the fields the are being considered top level fields and not sub fields a layout. The values are likely being stored in the DB under the name of the sub field. Each subsequent submission will overwrite the last values.

    The only way that I can think of doing this is to create an acf/save_post filter and in this filter you would need to update the flex field/layout/sub fields based on the current values of these other fields that are stored incorrectly. I’m not sure how you’d do this.

  • Thanks John.

    The big problem is : how can I target a layout in particular ?

    Imagine : I have a flexible content with two layouts “big team” and “little team”.
    I need to update the edit/save all fields of the layout “little team”. How can I target only this layout and its fields ?

  • You would need to look at the entire flex field and loop through the rows to find the one you want to update. Then use to update the flex field. Like I said, I don’t really know exactly how to do this. It would probably take me several hours to figure it out.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘acf_form + flexible content’ is closed to new replies.