Skip to content

Repeatable section with nested sections #256

@sudheer-ranga

Description

@sudheer-ranga

Hi,

I followed this gist.

https://github.com/michaeluno/admin-page-framework/blob/3.7.0/example/admin_page/advanced_usage/nesting/APF_Demo_AdvancedUsage_Nesting_SectionA.php

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.

screen shot 2016-07-31 at 12 01 45 am

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions