This topic contains 2 replies, has 2 voices, and was last updated by  vmrkela 3 years, 7 months ago.

  • Creator
    Topic
  • #1557

    vmrkela
    Participant

    Hello everyone,

    I have problem with Conditional Logic plugin when use Compound statements. Here is my code:

    array(
                    'name' => esc_html__('Show Call to Action', 'pi_framework'),
                    'id' => "{$prefix}vehicles_cta",
                    'desc' => esc_html__('Show Call to Action section.', 'pi_framework'),
                    'type' => 'checkbox',
                    'std' => '0',
                    'tab' => 'call_to_action'
                ),
                array(
                    'name' => esc_html__('Title', 'pi_framework'),
                    'id' => "{$prefix}vehicles_cta_title",
                    'desc' => esc_html__('Call to action title.', 'pi_framework'),
                    'type' => 'text',
                    'std' => '',
                    'tab' => 'call_to_action',
                    'visible' => array('pg_vehicles_cta', true)
                ),
                array(
                    'name' => esc_html__('Subtitle', 'pi_framework'),
                    'id' => "{$prefix}vehicles_cta_subtitle",
                    'desc' => esc_html__('Call to action subtitle.', 'pi_framework'),
                    'type' => 'text',
                    'std' => '',
                    'tab' => 'call_to_action',
                    'visible' => array('pg_vehicles_cta', true)
                ),
                array(
                    'name' => esc_html__('Button', 'pi_framework'),
                    'id' => "{$prefix}vehicles_cta_button",
                    'desc' => esc_html__('Show Call to Action button.', 'pi_framework'),
                    'type' => 'checkbox',
                    'std' => '0',
                    'tab' => 'call_to_action',
                    'visible' => array('pg_vehicles_cta', true)
                ),
                array(
                    'name' => esc_html__('Button text', 'pi_framework'),
                    'id' => "{$prefix}vehicles_cta_button_text",
                    'desc' => esc_html__('Enter button text.', 'pi_framework'),
                    'type' => 'text',
                    'std' => '',
                    'tab' => 'call_to_action',
                    'visible' => array(
                        array('pg_vehicles_cta', true),
                        array('pg_vehicles_cta_button', true)
                    )
                ),
                array(
                    'name' => esc_html__('Button URL', 'pi_framework'),
                    'id' => "{$prefix}vehicles_cta_button_url",
                    'desc' => esc_html__('Enter button URL.', 'pi_framework'),
                    'type' => 'text',
                    'std' => '',
                    'tab' => 'call_to_action',
                    'visible' => array(
                        array('pg_vehicles_cta', true),
                        array('pg_vehicles_cta_button', true)
                    )
                ),
                array(
                    'name' => esc_html__('Background color', 'pi_framework'),
                    'desc' => esc_html__('Set section background color.', 'pi_framework'),
                    'id' => "{$prefix}vehicles_cta_bkg_color",
                    'type' => 'color',
                    'tab' => 'call_to_action',
                    'visible' => array('pg_vehicles_cta', true)
                ),
                // Image Upload
                array(
                    'name' => esc_html__('Background image', 'pi_framework'),
                    'desc' => esc_html__('Set background image.', 'pi_framework'),
                    'id' => "{$prefix}vehicles_cta_bkg_image",
                    'type' => 'image_advanced',
                    'max_file_uploads' => 1,
                    'tab' => 'call_to_action',
                    'visible' => array('pg_vehicles_cta', true)
                ),

    So fields ‘vehicles_cta_button_text’ and ‘vehicles_cta_button_url’ depends on value of ‘vehicles_cta’ and ‘vehicles_cta_button’. But weird thing happen when you enable checkboxes:
    https://drive.google.com/file/d/0B7qqC1AVWhJ_MUVSY3BVOE5GRms/view?usp=drivesdk

    I tried to change ID of checkbox for button visibility to something that doesn’t starts with ‘pg_vehicles_cta’ and it was fine so it’s probably issue with regex or the way you are finding field values.

    Vladimir

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #1561

    Tan Nguyen
    Participant

    Hi Vladimir,

    Thanks for using and reporting. Exactly, this is the existing bug in Meta Box Conditional Logic.

    Long answer:
    When you define ‘pg_vehicles_cta’ in group field, if they clonable, so we can have ‘pg_vehicles_cta_1’, ‘pg_vehicles_cta_2’, etc… Or when you use conditional logic on special field which haven’t normal ID or class name or name so I’ll have to create a selector which match all ‘pg_vehicles_cta*’, so you can try to use different IDs in these field to make sure not match with ‘pg_vehicles_cta*’. We’re trying to fix this bug in next release.

    Short answer: Change ID to something doesn’t starts with ‘pg_vehicles_cta’ like you’ve did will works.

    Regards

    Tan Nguyen

    #1562

    vmrkela
    Participant

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Field visibility issue’ is closed to new replies.