Repeatable section with nested sections
Opened this issue · 2 comments
Hi,
I followed this gist.
I created a parent section and it has 3 sub sections.
$this->addSettingSections(
'my_parent_slug',
array(
'section_id' => 'section_id_parent',
'tab_slug' => 'my_tab_slug',
'title' => 'Repeat this section',
'repeatable' => true,
'collapsible' => array(
'toggle_all_button' => array( 'top-left', 'bottom-left' ),
),
'content' => array(
array(
'section_id' => 'section_id_1',
'title' => __( 'Section 1', 'admin-page-framework-loader' ),
),
array(
'section_id' => 'section_id_2',
'title' => __( 'Section 2', 'admin-page-framework-loader' ),
),
array(
'section_id' => 'section_id_3',
'title' => __( 'Section 3', 'admin-page-framework-loader' ),
),
)
),
array(
'section_id' => 'dont_repeat_this',
'tab_slug' => 'my_tab_slug',
)
);
Here is the field section
$this->apf->addSettingFields(
array('section_id_parent', 'section_id_1'),
array(
'field_id' => 'section_id_1_field_1',
'type' => 'text',
'title' => 'Section 1 Field 1',
),
array(
'field_id' => 'section_id_1_field_2',
'type' => 'text',
'title' => 'Section 1 Field 2',
),
array(
'field_id' => 'section_id_1_field_3',
'title' => __( 'Section 1 Field 3', 'admin-page-framework-loader' ),
'type' => 'select',
'default' => 'none',
'label' => array(
0 => __( 'Plain', 'admin-page-framework-loader' ),
1 => __( 'Red', 'admin-page-framework-loader' ),
2 => __( 'Green', 'admin-page-framework-loader' ),
3 => __( 'Blue', 'admin-page-framework-loader' ),
4 => __( 'Yellow', 'admin-page-framework-loader' ),
5 => __( 'Orange', 'admin-page-framework-loader' ),
),
'repeatable' => true
)
);
Similarly repeated for section 2 and 3
When I use repeatable in section_id_parent the repeat icon appears for each sub section along with the parent section.
How to make the parent section Repeat this section repeatable and not individual sections?
Attaching a screenshot.
Also, when I use inline_mixed type in the "Form Fields" section it doesn't show up.
array(
'field_id' => 'checkbox_number_select',
'type' => 'inline_mixed',
'title' => __( 'Checkbox, Number & Select', 'admin-page-framework-loader' ),
'content' => array(
array(
'field_id' => 'enable',
'type' => 'checkbox',
'label_min_width' => '',
'label' => __( 'Do something in', 'admin-page-framework-loader' ),
),
array(
'field_id' => 'interval',
'type' => 'number',
'label_min_width' => '',
'default' => 3,
'attributes' => array(
'style' => 'width: 80px',
),
),
array(
'field_id' => 'interval_unit',
'type' => 'select',
'label_min_width' => '',
'label' => array(
'hour' => __( 'hours', 'admin-page-framework-loader' ),
'day' => __( 'days', 'admin-page-framework-loader' ),
'week' => __( 'weeks', 'admin-page-framework-loader' ),
),
'default' => 'day',
),
array(
'field_id' => '_text',
'content' => __( 'to do something else.', 'admin-page-framework-loader' ),
),
),
),
This just shows the title Checkbox, Number & Select but nothing below it. I want to make this inline mixed field repeatable. What am I doing wrong.
Nice finding. I wasn't aware of it.
When a section has a nested item, it cannot be repeatable. I do not mind calling this behavior a bug. However, this cannot be fixed right away as it involves lots of changes. Sorry.
You may resort to nested fields instead to repeat a set of fields which includes different field types.
As for the inline_mixed
field type issue, can you create a new topic for it as it seems to be a different issue? Thanks.