Conditional Logic Not Working
Support › MB Conditional Logic › Conditional Logic Not WorkingResolved
- This topic has 5 replies, 2 voices, and was last updated 6 years, 8 months ago by
Anh Tran.
-
AuthorPosts
-
August 2, 2018 at 5:14 AM #10831
swartjie
ParticipantHey 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?
August 2, 2018 at 3:00 PM #10835Anh Tran
KeymasterHi,
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.
August 3, 2018 at 2:40 AM #10849swartjie
ParticipantHey Anh,
can you please explain further. I am not sure I understand what the problem is? And how to prevent it in the future?
August 3, 2018 at 4:11 PM #10858Anh Tran
KeymasterHi,
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.
August 3, 2018 at 4:27 PM #10860swartjie
ParticipantSo 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...
August 3, 2018 at 4:37 PM #10861Anh Tran
KeymasterThe easiest way is just set their IDs like:
prefix-text
andprefix-radio
. Please just don't make something likefield-one
andfield-one-two
.I'm working on fixing this bug. Until then, this is the only way to get rid off the bug.
-
AuthorPosts
- You must be logged in to reply to this topic.