Support

Account

Home Forums General Issues Overwrite value of group-field itself (using one of it's sub-fields) Reply To: Overwrite value of group-field itself (using one of it's sub-fields)

  • No, you cannot change this.

    A group field does not actually have a value, it only has sub fields that have values.

    And this is not 100% correct. A group field is actually a repeater field that has exactly 1 row. In a repeater field the value of the repeater field in the DB is the number of rows that have been saved in the repeater. Since this number is not really needed for a group field acf set it to an empty value.

    My suggestion would be to have 2 fields that are conditional on the true/false field rather than convert the text field to a group field. For example a text field and a group field that contains text fields for each language.

    Then I would create an acf/save_post action. In my filter I would check the value of the true/false field and depending on how it was set I would copy the default language value from/to the other field so that if the toggle is switched the value is present.

    Another option besides a acf/save_post filter would be to add custom JavaScript that transfers the content on the default language field back and forth when the toggle is changed.