My clone field "Services" has "Fields" set as "All fields from Section:services field group". My field group "Section: services" contains several fields including one called "Title" which I’ve set as required.
Now in my clone field "Services" I want "Title" to NOT be required. Problem is, if I try to make it not required in "Section:services", this update doesn’t extend to the "Services" clone field, where "Title" is still required.
Once a field group is cloned, is there not any way to changes those fields inside the cloned field?
EDIT:
My "Section: Services" field group containing the "Title" field whose required status I wanna change in the clone field:
My "Services" clone field containing "All fields from Section: Services field group" (it is within this clone field that I want my "Title" field to NOT be required any more):
2
Answers
You can achieve this programmatically.
In the example i am going to provide you with i have created two Field groups.
One called
Services
containing the field Title namedtitle
and the other calledClone Services
where on theFields
i have selectedAll fields from Services field group
, Display:Seamless (replace this field with selected fields)
and enabled the optionPrefix Field Names
. As a result the Title field in the Cloned group is namedclone_title
. You can replace theclone
andtitle
parts with the actual names of your fields.Now on its simple form you would need two hooks which can be placed in a custom plugin or in your functions.php file of your active theme. Please note that if you are not using a child theme, when you update your theme these would be overwritten and you would need to re-apply them.
With these 2 hooks you can achieve what you are looking for but on its simplest form. You could evolve much more both of these 2 hooks to perform much more sophisticated checks and rules depending on your needs.
Hope that helps!
Since you want to apply that modification only for a specific field, then you would need a
unique
value by which you would be able to target that specific field."ACF" assigns a
unique key
, for each field, called"Field Key"
. We could use this value to target any specific field that we would like to! All we need to find out this value, for any field, is to useScreen Options
and check theField Keys
checkbox, like the following screenshot:Now we can target that specific field like this:
Tested and works seamlessly on wordpress
Version 6.2
and ACFVersion 6.1.7
!