Conditional Logic Not Working

Support MB Conditional Logic Conditional Logic Not WorkingResolved

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #10831
    swartjieswartjie
    Participant

    Hey Guys,

    I am having a bit of a hard time with the conditional logic on a couple of fields...
    It seems it works perfectly on all others though, So I can't figure out what I am doing wrong...

    Can you please advise?

    The code added to the fields are as follows:

    array(
                    'id' => 'certified-load-capacity-of-concrete-floor-slab-fill-in',
                    'name' => 'Certified load capacity of concrete floor SLAB',
                    'type' => 'number',
                    'step' => '0.01',
                    'columns' => 6,
                    'tab'   =>  'site_assessment_of_the_data_center_location_2',
                    'visible' => array(
                        'when' =>
                        array(
                            array(
                                0 => 'certified-load-capacity-of-concrete-floor-slab',
                                1 => '!=',
                                2 => 'N/A',
                            ),
                            array(
                                0 => 'certified-load-capacity-of-concrete-floor-slab',
                                1 => '!=',
                                2 => 'Unknown',
                            ),
                        ),
                        'relation' => 'and',
                    )
                ),
                array(
                    'id' => 'certified-load-capacity-of-concrete-floor-slab',
                    'name' => 'Certified load capacity of concrete floor SLAB',
                    'type' => 'radio',
                    'options' => [
                        'Kg/m2' =>  'Kg/m2',
                        'Lbs/ft2'   =>  'Lbs/ft2',
                        'N/A'   =>  'N/A',
                        'Unknown'   =>  'Unknown'
                    ],
                    'inline' => 1,
                    'columns' => 6,
                    'tab'   =>  'site_assessment_of_the_data_center_location_2'
                )

    Basically the text input just remains visible no matter what option is chosen... Not sure what is causing it though... any way to debug?

    #10835
    Anh TranAnh Tran
    Keymaster

    Hi,

    After debugging your code, I found that it's an edge case where the plugin cannot get the correct value of the radio. The problem is when the plugin tries to get the radio inputs, it gets the number input as well. This is because the ID of the number field contains the id of the radio field.

    In this case, please change the id of the number field and the bug will go away.

    #10849
    swartjieswartjie
    Participant

    Hey Anh,

    can you please explain further. I am not sure I understand what the problem is? And how to prevent it in the future?

    #10858
    Anh TranAnh Tran
    Keymaster

    Hi,

    The problem is the plugin doesn't handle very well the case when a field's ID contains another field's ID. In this case the ID of the input contains the ID of the radio field. The plugin make some guests to find the correct elements. And in this case, it gets the wrong elements 🙁

    To prevent this bug, please set the IDs so no one contains another.

    #10860
    swartjieswartjie
    Participant

    So what would be an easy way to distinguish between the fields then?
    What if I just place a text in front of each field which would be unique to that field?

    meaning, I do something like substr(md5($field), 0, 5).'__original_field_name'
    That would make the end of the field then unique would it not?

    Or can they contain no parts of eachother? Which is a major bug if you ask me... And not something I should be dealing with really...

    #10861
    Anh TranAnh Tran
    Keymaster

    The easiest way is just set their IDs like: prefix-text and prefix-radio. Please just don't make something like field-one and field-one-two.

    I'm working on fixing this bug. Until then, this is the only way to get rid off the bug.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.