Kirki: Active callback in the Repeater control

Created on 21 Mar 2017  路  6Comments  路  Source: kirki-framework/kirki

Issue description:

Active callback does not work in the Repeater control

Version used: 2.3.7

(Did you try using the develop branch from github? There's a chance your issue has already been adressed there)

Tried the develop branch, but plugin could not be activated and return this message: "The plugin does not have a valid header."

Using theme_mods or options?

theme_mods

Code to reproduce the issue (config + field(s))

Regular active_callback argument.

Most helpful comment

Not yet, this will be implemented after v3.1 as it requires a significant rewrite of some oartsbof the code.

All 6 comments

Can you please post the code for your callback function here?

Sure. I have two selects, "select_one" and "select_two", inside the repeater control . Second select have the active_callback argument which is called when the option "two" is selected in the first select. I just now see that maybe the repeater fields names are not considered as setting and therefor is does not work.

Kirki::add_field( 'my_config', array(
    'type'       => 'repeater',
    'label'      => esc_attr__( 'Repeater Control', 'my_textdomain' ),
    'section'    => 'my_section',
    'priority'   => 10,
    'row_label'  => array(
        'type'  => 'field',
        'value' => esc_attr__( 'custom text', 'my_textdomain' ),
        'field' => 'section_one',
    ),
    'settings'    => 'my_setting',
    'fields' => array(
        'select_one' => array(
            'type'        => 'select',
            'label'       => esc_attr__( 'Title 1', 'my_textdomain' ),
            'default'     => 'one',
            'choices'     => array(
                'one'   => esc_attr__( 'One', 'my_textdomain' ),
                'two'   => esc_attr__( 'Two', 'my_textdomain' ),
                'three' => esc_attr__( 'Three', 'my_textdomain' ),
            ),
        ),
        'select_two' => array(
            'type'        => 'select',
            'label'       => esc_attr__( 'Title 2', 'my_textdomain' ),
            'default'     => 'columns',
            'choices'     => array(
                'four' => esc_attr__( 'Four', 'my_textdomain' ),
                'five' => esc_attr__( 'Five', 'my_textdomain' ),
                'six'  => esc_attr__( 'Six', 'my_textdomain' ),
            ),
            'active_callback'    => array(
                array(
                    'setting'  => 'select_one',
                    'operator' => '==',
                    'value'    => 'two',
                ),
            )
        )
    ),
) );

ok, now I understand what you mean.

You want to hide a field inside a row in the repeater depending on the value of another field inside the same row of the same repeater control?
If this is what you want then I'm afraid it's not currently supported.
You can hide the repeater field (the whole repeater, not subfields selectively) depending on the value of another field (not a sub-field) if you want, but nested fields can't control - or be controlled.

Thank you. Maybe you can consider this feature in the future.

Has this been implemented since maybe?

Not yet, this will be implemented after v3.1 as it requires a significant rewrite of some oartsbof the code.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fakrulislam picture fakrulislam  路  3Comments

manuelmoreale picture manuelmoreale  路  3Comments

hussainnayani picture hussainnayani  路  4Comments

ravishakya picture ravishakya  路  7Comments

Radzio1615 picture Radzio1615  路  4Comments