Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repeater not working in custom post type #4060

Closed
galaxyboy1988 opened this issue Mar 7, 2025 · 3 comments
Closed

repeater not working in custom post type #4060

galaxyboy1988 opened this issue Mar 7, 2025 · 3 comments

Comments

@galaxyboy1988
Copy link

Hi
repeater not working in custom post type

here is the code

Redux_Metaboxes::set_box(
	$sc_opt_name,
	array(
		'id'         => 'opt-event-simple-layout-one-section',
		'title'      => esc_html__( 'Simple Repeater With One Field', 'your-textdomain-here' ),
		'post_types' => array( 'sc_story' ),
		'position'   => 'normal', // normal, advanced, side.
		'priority'   => 'high', // high, core, default, low.
		'sections'   => array(
			array(
				'fields' => array(
					array(
						'id'       => 'opt-event-simple-layout-one-field',
						'type'     => 'repeater',
						'title'    => esc_html__( 'Repeater', 'your-textdomain-here' ),
						'subtitle' => esc_html__( 'Repeater', 'your-textdomain-here' ),
						'fields'   => array(
							array(
								'id'          => 'title_field',
								'type'        => 'text',
								'placeholder' => esc_html__( 'Title', 'your-textdomain-here' ),
							),

						),
					),
				),
			),
		),
	)
);

we look into the console and this is the error data:

redux-repeater.js?ver=4.3.13:65 Uncaught TypeError: Cannot read properties of undefined (reading 'repeater')
at HTMLFieldSetElement. (redux-repeater.js?ver=4.3.13:65:17)

@kprovance
Copy link
Member

This form was not filled out correctly. Specific instructions were provided. Ignoring them isn't an option.

@galaxyboy1988
Copy link
Author

galaxyboy1988 commented Mar 7, 2025

here is the entire code


if ( ! class_exists( 'Redux' ) ) {
    return; // Ensure Redux is installed and active
}

// Redux option name (unique identifier)
$sc_opt_name = "sc_story_options";

// Define Metabox Configuration
$sc_story_metaboxes = array(
    'id'            => 'sc_story_meta_box',
    'title'         => 'Story Meta Box',
    'post_types'    => array('sc_story'), // Attach to sc_story post type
    'position'      => 'normal', // normal, advanced, side
    'priority'      => 'high', // high, core, default, low
    'sections'      => array(
        array(
            'id'    => 'sc_story_settings',
            'title' => 'Story Settings',
            'fields' => array(
                
                array(
                    'id'       => 'story_author',
                    'type'     => 'text',
                    'title'    => 'Author Name',
                    'default'  => '',
                    'desc'     => 'Enter the author of this story.',
                ),
                array(
                    'id'       => 'story_date',
                    'type'     => 'date',
                    'title'    => 'Publication Date',
                    'default'  => '',
                    'desc'     => 'Select the publication date of the story.',
                ),
                array(
                    'id'       => 'story_featured',
                    'type'     => 'switch',
                    'title'    => 'Featured Story?',
                    'default'  => false,
                    'on'       => 'Yes',
                    'off'      => 'No',
                    'desc'     => 'Mark this story as featured.',
                ),
                
                //repeater start
                

                array(
                    'id'             => 'story_slides',
                    'type'           => 'repeater',
                    'title'          => esc_html__( 'Title', 'studiare' ),
                    'subtitle'       => esc_html__( '', 'studiare' ),
                    'desc'           => esc_html__( '', 'studiare' ),
                    //'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'   => 'story_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'     => true, // Allow the users to sort the repeater blocks or not
                    'fields'         => array(
                        array(
                            'id'          => 'story_title',
                            'type'        => 'text',
                            'placeholder' => esc_html__( 'Title', 'studiare' ),
                        ),
                        array(
                            'id'          => 'text_field',
                            'type'        => 'text',
                            'placeholder' => esc_html__( 'Text Field', 'studiare' ),
                        ),
                        array(
                            'id'      => 'select_field',
                            'type'    => 'select',
                            'title'   => esc_html__( 'Select Field', 'studiare' ),
                            'options' => array(
                                '1'      => esc_html__( 'Option 1', 'studiare' ),
                                '2'      => esc_html__( 'Option 2', 'studiare' ),
                                '3'      => esc_html__( 'Option 3', 'studiare' ),
                            ),
                            'placeholder' => esc_html__( 'Listing Field', 'studiare' ),
                        ),
                    ),
                )
                //repeater end
            ),
        ),
    ),
);

// Register Redux Metaboxes
if ( class_exists( 'Redux_Metaboxes' ) ) {
    Redux_Metaboxes::set_box($sc_opt_name,$sc_story_metaboxes);
} else {
    error_log( esc_html__( 'Redux_Metaboxes class not found. Ensure Redux Metaboxes extension is active.', 'studiare' ) );
}

the metabox added to page but there is an error in console:

Uncaught TypeError: Cannot read properties of undefined (reading 'repeater')
at HTMLFieldSetElement. (redux-repeater.js?ver=4.3.13:65:17)

note: the other fields saved in db but even the single repeater field does not

@kprovance
Copy link
Member

kprovance commented Mar 7, 2025

No. These instructions. Not negotiable.

Hello, and welcome to Redux Framework! We offer free bug reporting for our software. Since this service is free, we prefer to provide support our way. This means we ask you to first read the entire block of text below. Please do not post a few lines of what you think is wrong. Doing so without the required information below will get your ticket closed without a reply. We're sorry we have to enforce this policy now.

PLEASE, BEFORE YOU POST, READ THIS ENTIRE BLOCK OF TEXT!!!

We require all the information specified below for support. If this text block is ignored or the required data is not provided, your ticket will be automatically closed. NO exceptions. Thank you.

Are you a user reporting a bug with a theme or plugin?

Redux allows developers to include an options panel in their projects. Consequently, we do not offer support for folks who have purchased a theme or plugin that uses Redux. The responsibility of support for themes and plugins falls upon their author. We realize that some authors have included support links for Redux in their projects when they should not have. We apologize for that confusion and are taking steps to remedy that situation.

Please contact the author for support if you have purchased a theme or plugin that uses Redux. If the author is unavailable for help or has discontinued support, please refer to this before posting to our issue tracker: https://devs.redux.io/guides/basics/support-defined.html

Have a development usage question?

The issue tracker isn't the best place for usage questions. This format is not well-suited for questions & answers, and questions here don't have as much visibility as they do elsewhere. Before you ask a question, here are some resources to get help first:

Think you found a bug?

Please use the "BUG REPORT" template below. Remember, we are rabid about backward compatibility. Do not submit fixes that break previous ways of doing so, or we will reject them.

Also, we will reject your request unless you provide a Site Health Report. NO exceptions. If you do not include this information, and we close your ticket, please do not ask why. Instructions are listed below.

You MUST use Redux in dev mode when submitting an issue to us. If you are not or have circumvented our dev mode protocol, you are on your own. There could be information in your case that requires dev mode active (Compressed JavaScript, for example. We cannot diagnose issues with compressed JavaScript and why dev mode needs to be enabled).

If an error or notice appears on your screen, please cut and paste it into your issue. PLEASE, do not say you received a critical error' without telling us what the error or notice is. If you do so, the ticket will be closed without a reply.

Before you post, check the JavaScript!

Sometimes, an issue may be tied to JavaScript. To make this determination, you will need to check the JavaScript console. To do this, ensure your web browser is the topmost window. On your keyboard, press CTRL+SHIFT+I. The JavaScript console will open. If there are notices or errors there, please cut and paste them into your issue. We would prefer a cut-and-paste since it will include all pertinent information. Also, Redux dev mode must be enabled so an accurate line number may be reported.

Site Health Report

Steps to reproduce

Expected Behavior

Actual Behavior

Any Error Details (PHP/JavaScript)

Also, Metaboxes cannot be used standalone. If that's all you're after, I would search for CMB2 Metaboxes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants