Support » Plugin: Admin Page Framework » How to get values from repeatable sections

  • yst14

    (@yst14)


    I am using the latest version of APF and I have a repeatable section. This section contains a number field and a textarea field.

    How do I get and use these repeatable sections?

    Thanks
    Ben

    
     public function load_wc_groups_email( $oAdminPage ) {    // load_{page slug}
            
            $this->addSettingSections(
                array(
                    'section_id'        => 'client_email_custom_message',
                    'title'             => 'Client Email Custom Message',
                    'repeatable'    => true,
                )
            );
        
            $this->addSettingFields(
                'client_email_custom_message', // section id
                array(
                    'field_id'          => 'number',
                    'title'             => __( 'Customer Group ID', 'admin-page-framework-loader' ),
                    'type'              => 'number',
                ),
                array(
                    'field_id'          => 'textarea',
                    'title'             => __( 'Email Text', 'admin-page-framework-loader' ),
                    'type'              => 'textarea',
                    'rich'              => true,
                    'default'           => '<h2 id="h2thanks">Delivery Timeline</h2><p class="pthanks">Thank you for making this purchase!</p><p class="pthanks">Estimated delivery times are 3-5 days.</p>',
                ),
                array(
                    'field_id'  => '_submit',
                    'type'      => 'submit',
                    'save'      => false,
                    'label'     => 'Save',
                )
            );
        }
    • This topic was modified 4 weeks, 1 day ago by  yst14.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author miunosoft

    (@miunosoft)

    Dump the data using {your prefix}_AdminPageFramework_Debug::log( $data ). Then a log file will be created in your wp-content directory. Make sure your site debug mode is enabled. You’ll see the structure of the multi-dimensional array. Then you can use {your prefix}_AdminPageFramework_Utility::getElement( $data, array( 'key_of_1st_depth', 'key_of_2nd_depth', 'key_of_3rd_depth' ... ) )

    Hope this helps.

    Hi,

    Sorry, I’m not quite understanding.

    The Debug::log doesn’t output anything. I’m also not sure how getElement gives me a foreach for each of my sections in my repeatable section?

    Thanks
    Ben

    Managed to get my foreach working as below however it doesn’t seem to be working for the first section. I have 3 sections in the admin however only the last 2 sections are outputted.

    ` $my_options = get_option( ‘NoouWcGroupsNotes’ );
    if(!empty($my_options) === true ){
    foreach($my_options[‘my_post_meta_section’] as $row){
    echo ‘Group Number: ‘.$row[‘group_number’];
    echo ‘Group Text: ‘.$row[‘group_textarea’];
    }
    }`

    returns:

    Group Number: 6Group Text: 6 textGroup Number: 4Group Text: email text

    Plugin Author miunosoft

    (@miunosoft)

    You want to do something like this.

    
    {your prefix}_AdminPageFramework_Debug::log( get_option( ‘NoouWcGroupsNotes’ ) )
    

    Make sure you change the part {your prefix} to your actual prefix string.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.