add_tab within field groups
Version
- Carbon Fields: 3.3.0
- WordPress: 5.6.2
- PHP: 7.2
Expected Behavior
On the backend interface, I'd like to add tabs to fields WITHIN a complex layout rather than on the container itself.
Actual Behavior
The ->add_tab parameter only seems to work at the container level. However, in a series of complex fields, I'd like the ability to group some of the fields within a specific row, as a tabbed layout for clarity and ease of data entry.
As you can see, in the example below I have various complex fields called content_full_width, header and at_a_glance (and many more!). However, I'd like the ability to display the four fields in content_full_width within 2 tabs as indicated with the pseudo-code.
However it seems I can't do that as the ->add_tab only works at the container level?
Container definition
// Flexible container
add_action( 'carbon_fields_register_fields', 'fluidal_page_builder' );
function fluidal_page_builder() {
$add_new_row = array( 'plural_name' => 'rows', 'singular_name' => 'row');
Container::make( 'post_meta', __( 'Flexible content', 'crb' ))
->where( 'post_type', '=', 'page' )
->add_fields( array(
Field::make( 'html', 'fluidal_page_builder_info' )
->set_html( '<p>Build a page by clicking the "Add row" button and selecting the type of content you wish to add. Then complete the fields as appropriate. Drag a row to change the order of it. Delete a row by clicking on the rubbish bin icon.</p>'
),
Field::make( 'complex', 'flexible', 'Row' )
->setup_labels( $add_new_row )
->add_fields( 'content_full_width', 'Content: full width', array(
// TAB HERE
Field::make( 'text', 'title', 'Title' ),
Field::make( 'rich_text', 'body_content', 'Body text' )
->set_settings( array(
'media_buttons' => true,
'tinymce' => true
)),
// ANOTHER TAB HERE
Field::make( 'image', 'background_image', 'Background image' ),
Field::make( 'color', 'background_colour', 'Background' )
->set_palette( array( '#FF0000', '#00FF00', '#0000FF' ) )
))
->add_fields( 'header', 'Header content', array(
Field::make( 'rich_text', 'text', 'Enter header text here' )
))
->add_fields( 'at_a_glance', 'At a glance content', array(
Field::make( 'rich_text', 'text', 'Enter text here' )
)),
));
}
Steps to Reproduce the Problem
You can see the problem as detailed above.
Any ideas? @jorostoyanov
Hi @duncanarrow
Yes, you can only use add_tab on the container itself.
I will leave this issue open and tag it as "Feature" in order to keep it in mind for future releases.
Hello @jorostoyanov,
Any updates on this? Would be awesome if this feature will be implemented soon.
I'm also looking for adding tabs within a complex field to make the admin interface more user friendly, because I am starting to get loads of options.
Cheers!