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 https://www.advancedcustomfields.com/resources/acf-save_post/ 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.
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 https://www.advancedcustomfields.com/resources/update_field/ 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)
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