->add_fields of Complex Fields does not allow multiple calls
martin-neumann-gurus opened this issue · 0 comments
martin-neumann-gurus commented
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' ) )
]);