Not display "" Add More" button for type repeater when use in Metabox
Akhill2020 opened this issue · 1 comments
Akhill2020 commented
Hello
I want to add metabox in my theme for post type 'page' I have add metbox in my page but when I try to add "Repeater" type option in metabox it does not show the "Add" and "Delete" button to add more fields.
Screenshot: https://prnt.sc/obatxCvXM4Ar
I can see the Add and delete button in my theme option section for repeater type but not when I use repeater in metabox.
Screenshot:https://www.screenpresso.com/=5Rove
I am using default data for creating the meta box
// Standard metabox.
Redux_Metaboxes::set_box(
$opt_name,
array(
'id' => 'opt-metaboxes',
'title' => esc_html__( 'Metabox Options', 'your-textdomain-here' ),
'post_types' => array( 'page', 'post' ),
'position' => 'normal', // normal, advanced, side.
'priority' => 'high', // high, core, default, low.
'sections' => array(
array(
'title' => esc_html__( 'Basic Field', 'your-textdomain-here' ),
'id' => 'opt-basic-fields',
'desc' => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . ' <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>',
'icon' => 'el-icon-cogs',
'fields' => array(
array(
'id' => 'opt-checkbox',
'type' => 'checkbox',
'title' => esc_html__( 'Checkbox', 'your-textdomain-here' ),
'subtitle' => esc_html__( 'Basic Checkbox field.', 'your-textdomain-here' ),
'default' => $hastitle,
),
array(
'id' => 'dashboard_columns_page',
'type' => 'select',
'multi' => true,
'title' => esc_html__('Number of columns in the dashboard', 'woffice'),
'desc' => esc_html__('This is only for non-mobiles devices, because it is responsive.', 'woffice'),
'options' => array(
'1' => esc_html__( '1 Columns', 'woffice' ),
'2' => esc_html__( '2 Columns', 'woffice' ),
'3' => esc_html__( '3 Columns', 'woffice' )
),
// 'default' => $dashboard_columns,
),
array(
'id'=>'register_custom_domain_array_page',
'type' => 'multi_text',
'title' => __('Allow only a certain Email domain to register.', 'woffice'),
'desc' => __('We will check if that domain is in the email address in order to register to the site. Example : gmail.com','woffice'),
// 'default' => $register_custom_domain_array_default,
),
array(
'id' => 'switch-on',
'type' => 'switch',
'title' => esc_html__( 'Switch On', 'your-textdomain-here' ),
'subtitle' => esc_html__( 'Look, it\'s on!', 'your-textdomain-here' ),
'default' => 1,
),
),
),
array(
'title' => esc_html__( 'Text Field', 'your-textdomain-here' ),
'desc' => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . ' <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>',
'icon' => 'el-icon-cog',
'id' => 'opt-text-fields',
'subsection' => true,
'fields' => array(
array(
'title' => esc_html__( 'Text Field', 'your-textdomain-here' ),
'id' => 'opt-text',
'type' => 'text',
),
),
),
array(
'title' => esc_html__( 'Color Field', 'your-textdomain-here' ),
'desc' => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . ' <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>',
'icon' => 'el-icon-pencil',
'id' => 'color-section',
'fields' => array(
array(
'id' => 'opt-color',
'type' => 'color',
'title' => esc_html__( 'Color Field', 'your-textdomain-here' ),
'default' => '#333333',
'required' => array( 'opt-layout', '=', 'on' ),
),
),
),
array(
'id' => 'repeater-field-id-test',
'type' => 'repeater',
'title' => esc_html__( 'Repeater Demo', 'your-textdomain-here' ),
'full_width' => true,
'subtitle' => esc_html__( 'Repeater', 'your-textdomain-here' ),
'item_name' => '',
'sortable' => true,
'active' => false,
'collapsible' => false,
'fields' => array(
array(
'id' => 'title_field',
'type' => 'text',
'placeholder' => esc_html__( 'Title', 'your-textdomain-here' ),
),
array(
'id' => 'textarea_field',
'type' => 'textarea',
'placeholder' => esc_html__( 'Text Field', 'your-textdomain-here' ),
'default' => 'Text Field here',
'title' => esc_html__( 'Title', 'your-domain-here' ),
),
array(
'id' => 'select_field',
'type' => 'select',
'multi' => true,
'title' => esc_html__( 'Select Field', 'your-textdomain-here' ),
'options' => array(
'1' => esc_html__( 'Option 1', 'your-textdomain-here' ),
'2' => esc_html__( 'Option 2', 'your-textdomain-here' ),
'3' => esc_html__( 'Option 3', 'your-textdomain-here' ),
),
'placeholder' => esc_html__( 'Listing Field', 'your-textdomain-here' ),
),
array(
'id' => 'switch_field',
'type' => 'switch',
'placeholder' => esc_html__( 'Switch Field', 'your-textdomain-here' ),
'default' => true,
),
array(
'id' => 'text_field',
'title' => esc_html__( 'Text Field', 'your-textdomain-here' ),
'type' => 'text',
'placeholder' => esc_html__( 'Text Field', 'your-textdomain-here' ),
//'required' => array( 'switch_field', '=', false ),
'default' => 'Text Field here',
),
),
),
),
)
);```
kprovance commented
Your config is incorrect. The repeater field needs to be inside a section block. It cannot be the actual section. Please try this:
<?php
/**
* Redux Framework Sample Metabox Config File
* For full documentation, please visit: http:https://devs.redux.io/
* Metabox Lite support the following fields only: checkbox, radio, text, textarea, media, & color
* Post Format and Post Template options are not avaialble in Metabox Lite.
* These advanced options are available in Redux Pro.
*
* @package Redux Framework
*/
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'Redux_Metaboxes' ) ) {
return;
}
// Standard metabox.
Redux_Metaboxes::set_box(
$opt_name,
array(
'id' => 'opt-metaboxes',
'title' => esc_html__( 'Metabox Options', 'your-textdomain-here' ),
'post_types' => array( 'page', 'post' ),
'position' => 'normal', // normal, advanced, side.
'priority' => 'high', // high, core, default, low.
'sections' => array(
array(
'title' => esc_html__( 'Basic Field', 'your-textdomain-here' ),
'id' => 'opt-basic-fields',
'desc' => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . ' <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>',
'icon' => 'el-icon-cogs',
'fields' => array(
array(
'id' => 'opt-checkbox',
'type' => 'checkbox',
'title' => esc_html__( 'Checkbox', 'your-textdomain-here' ),
'subtitle' => esc_html__( 'Basic Checkbox field.', 'your-textdomain-here' ),
'default' => $hastitle,
),
array(
'id' => 'dashboard_columns_page',
'type' => 'select',
'multi' => true,
'title' => esc_html__('Number of columns in the dashboard', 'woffice'),
'desc' => esc_html__('This is only for non-mobiles devices, because it is responsive.', 'woffice'),
'options' => array(
'1' => esc_html__( '1 Columns', 'woffice' ),
'2' => esc_html__( '2 Columns', 'woffice' ),
'3' => esc_html__( '3 Columns', 'woffice' )
),
// 'default' => $dashboard_columns,
),
array(
'id'=>'register_custom_domain_array_page',
'type' => 'multi_text',
'title' => __('Allow only a certain Email domain to register.', 'woffice'),
'desc' => __('We will check if that domain is in the email address in order to register to the site. Example : gmail.com','woffice'),
// 'default' => $register_custom_domain_array_default,
),
array(
'id' => 'switch-on',
'type' => 'switch',
'title' => esc_html__( 'Switch On', 'your-textdomain-here' ),
'subtitle' => esc_html__( 'Look, it\'s on!', 'your-textdomain-here' ),
'default' => 1,
),
),
),
array(
'title' => esc_html__( 'Text Field', 'your-textdomain-here' ),
'desc' => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . ' <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>',
'icon' => 'el-icon-cog',
'id' => 'opt-text-fields',
'subsection' => true,
'fields' => array(
array(
'title' => esc_html__( 'Text Field', 'your-textdomain-here' ),
'id' => 'opt-text',
'type' => 'text',
),
),
),
array(
'title' => esc_html__( 'Color Field', 'your-textdomain-here' ),
'desc' => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . ' <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>',
'icon' => 'el-icon-pencil',
'id' => 'color-section',
'fields' => array(
array(
'id' => 'opt-color',
'type' => 'color',
'title' => esc_html__( 'Color Field', 'your-textdomain-here' ),
'default' => '#333333',
'required' => array( 'opt-layout', '=', 'on' ),
),
),
),
array(
'title' => esc_html__( 'Repeater Field', 'your-textdomain-here' ),
'desc' => esc_html__( 'Redux Framework was created with the developer in mind. It allows for any theme developer to have an advanced theme panel with most of the features a developer would need. For more information check out the Github repo at:', 'your-textdomain-here' ) . ' <a href="https://github.com/ReduxFramework/Redux-Framework">https://github.com/ReduxFramework/Redux-Framework</a>',
'icon' => 'el-icon-pencil',
'id' => 'repeater-section',
'fields' => array(
array(
'id' => 'repeater-field-id-test',
'type' => 'repeater',
'title' => esc_html__( 'Repeater Demo', 'your-textdomain-here' ),
'full_width' => true,
'subtitle' => esc_html__( 'Repeater', 'your-textdomain-here' ),
'item_name' => '',
'sortable' => true,
'active' => false,
'collapsible' => false,
'fields' => array(
array(
'id' => 'title_field',
'type' => 'text',
'placeholder' => esc_html__( 'Title', 'your-textdomain-here' ),
),
array(
'id' => 'textarea_field',
'type' => 'textarea',
'placeholder' => esc_html__( 'Text Field', 'your-textdomain-here' ),
'default' => 'Text Field here',
'title' => esc_html__( 'Title', 'your-domain-here' ),
),
array(
'id' => 'select_field',
'type' => 'select',
'multi' => true,
'title' => esc_html__( 'Select Field', 'your-textdomain-here' ),
'options' => array(
'1' => esc_html__( 'Option 1', 'your-textdomain-here' ),
'2' => esc_html__( 'Option 2', 'your-textdomain-here' ),
'3' => esc_html__( 'Option 3', 'your-textdomain-here' ),
),
'placeholder' => esc_html__( 'Listing Field', 'your-textdomain-here' ),
),
array(
'id' => 'switch_field',
'type' => 'switch',
'placeholder' => esc_html__( 'Switch Field', 'your-textdomain-here' ),
'default' => true,
),
array(
'id' => 'text_field',
'title' => esc_html__( 'Text Field', 'your-textdomain-here' ),
'type' => 'text',
'placeholder' => esc_html__( 'Text Field', 'your-textdomain-here' ),
//'required' => array( 'switch_field', '=', false ),
'default' => 'Text Field here',
),
),
),
)
)
),
)
);