Cannot read property '0' of undefined in SetRuleInputValue
I am implementing querybuilder with variables. At one point, using the operator 'between' (2 inputs) with scalar values lead to this error after calling setRules. The error happens when trying to set the 2 values of the operator "between".
I ended up by fixing QueryBuilder.prototype.setRuleInputValue in query-builder.standalone.js. The following line (on switch default): $value.find('[name=' + name + ']').val(value[i]).trigger('change'); was replaced with if (value != undefined) $value.find('[name=' + name + ']').val(value[i]).trigger('change');
Error happens because 'value' is undefined at this point. Subsequent calls to the function with appropriate value (!= undefined) work fine.
Thinking about it, the 'if' should probably be better right before the 'for', not going into the loop if 'value' is undefined.
Do what you want with it. I fixed my issue anyway, maybe others will eventually come to this.
Paul
Please provide a simple test case of the bug.
There is no simple test case.
If you want to see the impact of this bug go to www.imsmart.tech, open an account, create a numeric variable, then create a trigger using the operator between. You will not need to define any action, so delete any action. After the trigger is saved, come back and edit it but set your browser debugger to go to file /Components/jQuery-QueryBuilder/dist/js/query-builder.standalone.js around line 2127. Set a breakpoint there. You'll see that when you edit the trigger with a between operator you come to this point in code where value = undefined and that caused the error before I added the if clause.
That's the best I can do for the test case.
Basic usage shows that there is no problem https://jsfiddle.net/1cs7pqer/ And unfortunately I have no time to dig in your code. I cannot blindly change the code without reproducing the issue.
Of course it works but no problem if you don't have time to dig in this. I don't think this if clause harms anything but it's your code, your call, and I understand that you need to replicate.
Thank you.
Hi, just wanted to add, I was coming across the same issue with the "between" operator. The error was happening at QueryBuilder.setRuleInputValue (query-builder.js:2518).
Adding a default value appears to have solved the issue.