kirki icon indicating copy to clipboard operation
kirki copied to clipboard

Required arguments don't work on customizr page load

Open DevelopOnline opened this issue 11 years ago • 2 comments

Hi there, When customizer page loads, required fields display all the time no matter what is selected in the parent setting, and after re-select parent field, it works. But after (save &) refresh customizer page, it doesn't work again and required fields display again :(

Kirki version: master branch ver 0.7.1

Any solution?!

Thanks in advance

DevelopOnline avatar Mar 27 '15 18:03 DevelopOnline

Fixed in the develop branch. :) See https://github.com/aristath/kirki/commit/30a92cbcfa22d953597ab56dbd7f60c70b97e76e

However, we now define "required" arguments a bit different:

    $controls[] = array(
        'type'        => 'checkbox',
        'setting'     => 'checkbox_demo2',
        'label'       => __( 'This is the label', 'kirki' ),
        'description' => __( 'This is the control description', 'kirki' ),
        'help'        => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ),
        'section'     => 'checkbox_section',
        'default'     => 0,
        'priority'    => 10,
        'required'    => array(
            array(
                'setting'  => 'checkbox_demo',
                'operator' => '==',
                'value'    => '0',
            )
        )
    );

This change was made so that we may make this a bit more modular and allow for better control based on more control types.

aristath avatar Mar 28 '15 13:03 aristath

Hi @aristath

I am in need of you help. I am started learning kirki but i cant move on. I cant make the required argument to work.

When you have some time please do help me check whats wrong with my code.

Below is the code i created.

$fields[] = array(
    'type'        => 'radio',
    'settings'    => 'htypes',
    'label'       => __( '', 'kirki' ),
    'description' => __( '', 'kirki' ),
    'section'     => 'header_types',
    'priority'    => 10,
    'choices'     => array(
        'widget' => __( 'Widgetized', 'kirki' ),
        'predef' => __( 'Predefined', 'kirki' ),
    ),
);

$fields[] = array(
    'type'        => 'radio-image',
    'settings'    => 'headtype',
    'label'       => __( '', 'kirki' ),
    'description' => __( '', 'kirki' ),
    'section'     => 'header_types',
    'priority'    => 20,
    'default'    => 'htypes1',
    'choices'     => array(
        'htypes1' => __( 'First Option', 'kirki' ),
        'htypes2' => __( 'Second Option', 'kirki' ),
    ),
    'required'  => array(
        array(
            'setting'  => 'htypes',
            'value'    => 'predef',
            'operator' => '==',
        ),
    )
);

randomideas avatar Jun 11 '15 20:06 randomideas