• Hi , I have a problem with my repeater field

    I registered my repeater extension and I defined an repeater field in my theme options page

    Now the field is displayed well and I can save something in my fields , but when I want to get my fields value , It returns empty string

    I use below code to get my options value

    $settting = get_option('vitrin_option');
    var_dump($settting['vitrin_options_custom_menu_repeater']);

    Bottom code returns this code below

    array(1) { ["redux_repeater_data"]=> array(3) { [0]=> array(1) { ["title"]=> string(0) "" } [1]=> array(1) { ["title"]=> string(0) "" } [2]=> array(1) { ["title"]=> string(0) "" } } }
    

    But I saved some data in this fields

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Kev Provance

    (@kprovance)

    The first thing I would do is get rid of the extension. It’s no doubt outdated. Repeater is now part of the Redux core. Please make sure you are using the latest version of Redux and attempt the code again. If the problem persists, I will need you to post your ENTIRE options config so I may try it here.

    Thread Starter Amirhossein yaldoughie

    (@mrmizban)

    ok, I update it to latest version

    Now it’s same as previous and return empty array

    array(1) { ["redux_repeater_data"]=> array(3) { [0]=> array(1) { ["title"]=> string(0) "" } [1]=> array(1) { ["title"]=> string(0) "" } [2]=> array(1) { ["title"]=> string(0) "" } } }

    I defined the field like this

    Redux::setSection($opt_name,  array(
        'title' => esc_html__('Repeater Field', 'your-textdomain-here'),
        'icon' => 'el-icon-thumbs-up',
        'fields' => array(
            array(
                'id'             => 'repeater-field-id',
                'type'           => 'repeater',
                'title'          => esc_html__('Title', 'your-textdomain-here'),
                'subtitle'       => esc_html__('', 'your-textdomain-here'),
                'desc'           => esc_html__('', 'your-textdomain-here'),
                //'group_values' => true, // Group all fields below within the repeater ID
                //'item_name'    => '', // Add a repeater block name to the Add and Delete buttons
                //'bind_title'   => '', // Bind the repeater block title to this field ID
                //'static'       => 2, // Set the number of repeater blocks to be output
                //'limit'        => 2, // Limit the number of repeater blocks a user can create
                //'sortable'     => false, // Allow the users to sort the repeater blocks or not
                'fields'         => array(
                    array(
                        'id'          => 'title_field',
                        'type'        => 'text',
                        'placeholder' => esc_html__('Title', 'your-textdomain-here'),
                    ),
                    array(
                        'id'          => 'text_field',
                        'type'        => 'text',
                        'placeholder' => esc_html__('Text Field', 'your-textdomain-here'),
                    ),
                    array(
                        'id'      => 'select_field',
                        'type'    => 'select',
                        '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'),
                    ),
                )
            )
        )
    ));

    It work in wp dashboard and I can save items and values , But when I want to get values , It return empty array

    Plugin Author Kev Provance

    (@kprovance)

    You’ve got the grouped_values arg set to false. This means the variable you are attempting to access will, in fact, be empty.

    To get the values, you’ll have to access the repeater’s field IDs directly:

    var_dump($settting['title_field']);
    

    To understand the difference of the two modes and how to access the data, see the help page for the Repeater field: https://devs.redux.io/core-extensions/repeater.html

    Good luck.

    • This reply was modified 1 year, 11 months ago by Kev Provance.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘my repeater field return nothing’ is closed to new replies.