In the video for the clone field there’s a demonstration of a button field that has several ‘url’ fields and then it pulls whichever one is saved (page or url)
I tried to do a similar thing, but my ‘url’ field is coming back false.
I have a url field, a page link field, and a file field, all named url and showing conditionally based on type. I choose the appropriate type (post), select a post.. but the
url field is coming back false.
Is there something I might be missing here?
I just tried the same thing with 4 types of fields all named “url”; Page Link, URL, File and Image. These all worked on the front end. Is there another field also being saved on the same post with the same name?
Having fields with the same name, when all but one of the fields is hidden by conditional logic, will work in theory because the values in the fields hidden by conditional logic are not submitted. Basically, only one field with that name can be submitted, if there are multiple fields submitted with the same name then you will run into visible problems.
There are hidden problems though, for example, if you save a post with “File” selected and then switch to “URL”, the file field named “url” will be hidden and the URL field named “url” will be shown relieving a Post ID as the current value of the field. What happens is that when the field named “url” is saved that the field key pointer is updated to the currently active field type. Honestly, I did not know that this shortcut for field names when using conditional logic existed, and now that I know I probably would not use it. The reason being that the odd display of values when switching the selection would just confuse my average client.
Anyway, it does seem to be working, I would look at the field names of other fields on the page that are not associated with that group. If you’re cloning the group more than once the you need to be sure to use the field name prefix feature.
Is there another field also being saved on the same post with the same name?
I just had a similar problem – I have a group of flexible fields called “image_blocks” that I was cloning into a field called “image_blocks” in another group. I didn’t realize that every time I saved the post, my flexible fields were being overwritten by the parent Clone field.
I would recommend naming the Clone field something like url_clone to avoid collisions, if that’s your problem. It would be great if the plugin could automatically detect confusion like that.
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!
© 2020 Advanced Custom Fields. Subscribe