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

->add_fields of Complex Fields does not allow multiple calls #1243

Open
martin-neumann-gurus opened this issue Jul 26, 2024 · 0 comments
Open

Comments

@martin-neumann-gurus
Copy link

Version

  • Carbon Fields: 3.6
  • WordPress:
  • PHP: 8.2

Expected Behavior

In ->add_fields of a container I can make multiple calls to subsequently add more fields

Actual Behavior

It throws an error that the group name is already in use.
I see in the documentation the option to create named groups. But at least when no name is defined, I would expect the function to add more fields instead of throwing an error.

Container definition

$complex = Field::make( 'complex', 'fields', __( 'Page Definitions', 'webgurus-mautic' ) )
            ->add_fields( [
                Field::make( 'select', 'page', __( 'Name of Confirmation Page' , 'webgurus-mautic') ) ->set_options( array('\Webgurus\Admin\MauticAdmin', 'getPages' ) ),
                Field::make( 'select', 'confirm_check', __( 'Segment Check' , 'webgurus-mautic') ) ->set_options( [
                    's' =>  __( 'Check if subscribed' , 'webgurus-mautic'),
                    'u' =>  __( 'Check if unsubscribed' , 'webgurus-mautic'),
                    'n' =>  __( 'No Segment Check' , 'webgurus-mautic') 
                ]),
                Field::make( 'select', 'confirm_segment', __( 'Segment to confirm' , 'webgurus-mautic') ) ->set_options( array('\Webgurus\Admin\MauticAdmin', 'getSegments' ) ),
                Field::make( 'text', 'confirmed_text', __( 'Text to show if confirmation action will be taken (segment check false)', 'webgurus-mautic' ) ),
                Field::make( 'text', 'resolved_text', __( 'Text to show if confirmation action already resolved (segment check already true)', 'webgurus-mautic' ) ),
            ]);
        $complex->add_fields( [
                Field::make( 'radio', 'do_not_contact', __( 'Do not Contact (Email Channel)', 'webgurus-mautic' ) ) ->set_options( array('add' => __( 'Add' , 'webgurus-mautic'), 'remove' => __( 'Remove' , 'webgurus-mautic'), '' => __( 'Maintain Unchanged' , 'webgurus-mautic'))),
                Field::make( 'select', 'send_email', __( 'Send Email' , 'webgurus-mautic') ) ->set_options( array('\Webgurus\Admin\MauticAdmin', 'getEmails' ) )
                ]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant