Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cater for field type clone #9

Open
bobbingwide opened this issue Jul 7, 2023 · 1 comment
Open

Cater for field type clone #9

bobbingwide opened this issue Jul 7, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@bobbingwide
Copy link
Owner

bobbingwide commented Jul 7, 2023

The clone field type allows the user to use fields that have already been defined in other Field groups.

From the documentation at https://www.advancedcustomfields.com/resources/clone/

The clone field allows you to select and display existing fields. It does not duplicate any fields in the DB, instead, it loads and displays the selected fields at run-time.

You may also select one (or more) field groups making it possible to load in ‘module’ groups. A good example of this can be seen with the screenshots below where a single field group is created for ‘Button’ information. This field group is then ‘cloned’ when a button is needed.

The clone field may be used in one of two ways.

  1. It can replace itself with the selected fields (seamless)
  2. or display the selected fields as a group of sub fields.
@bobbingwide bobbingwide added the enhancement New feature or request label Jul 7, 2023
@bobbingwide bobbingwide self-assigned this Jul 7, 2023
@bobbingwide
Copy link
Owner Author

bobbingwide commented Jul 7, 2023

The clone field may be used in one of two ways. It can replace itself with the selected fields (seamless)

To implement this it would appear that we'd need to defer the rendering/ echoing of the field classes to the callback method.

function render()
    {
        //echo "Rendering block";
        $this->field_name = get_field('acf-field-name');
        // What if the field name isn't set?

        $this->field_info = get_field_object($this->field_name, $this->post_id);
        if ($this->field_info) {
            $this->field = get_field($this->field_name, $this->post_id);
            $this->render_acf_field_classes($this->field_name, $this->field_info['type'], $this->block);
            $this->render_acf_field_contents();
            echo '</div>';
        } else {
            $this->render_no_field_info();
        }

    }

In actual fact, what happens is that when a field type of cloned is marked as seamless, then each field is a separate field.
See trace?

bobbingwide added a commit that referenced this issue Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant