Wappler Version : 3.3.5
Operating System : Mac
NODEJS MySql8 Project.
Expected behavior
I have a form with inputs named as per this document: W3C HTML JSON form submission - e.g. query[bool][must][match_phrase][primary.job.title.name][query]
I expect the form to submit.
Actual behavior
What actually happens?
I receive the following error within dev tools. I have tried all variations of declaring the input type in the $_POST Schema, i've tried changing from objects, to arrays (where appropriate) - but nothing gets me past this error.
{status: "500", message: "Cannot read property 'primary.job.title.name' of undefined",…}
message: "Cannot read property 'primary.job.title.name' of undefined"
stack: "TypeError: Cannot read property 'primary.job.title.name' of undefined↵ at Object.validateFields (/opt/node_app/lib/validator/index.js:48:31)↵ at Object.validateFields (/opt/node_app/lib/validator/index.js:60:28)↵ at Object.validateFields (/opt/node_app/lib/validator/index.js:60:28)↵ at Object.validateFields (/opt/node_app/lib/validator/index.js:60:28)↵ at Object.validateFields (/opt/node_app/lib/validator/index.js:60:28)↵ at Object.init (/opt/node_app/lib/validator/index.js:11:24)↵ at runMicrotasks (<anonymous>)↵ at processTicksAndRejections (internal/process/task_queues.js:97:5)↵ at async App.define (/opt/node_app/lib/core/app.js:185:13)"
status: "500"
Is this for sending the whole $_POST.query json to the ES API?
If so, can you not just declare $_POST.query (don’t worry about the schema) under Globals and add it as one of the parameters of the API call?
Hi @bpj! Unfortunately not, as that would then output parameters that might be empty/null if the end user hasn’t used the field.
Also as another note - I actually have nothing in the workflow right now to try to debug the issue - this happens simply when trying to submit the form.
I thought the method of using a hidden field with a value set by the visible field but also being disabled if the value was empty would solve sending fields that weren’t populated. Did it not work?
Maybe I am misunderstanding your suggeston, but if I ignore the approach where I generate the Schema on the Front End with the aforementioned naming properties, and instead use a more traditional parameter + value approach (with the value being one of the field inputs) then the output Schema will include parameter + null value if there is no value - which will cause the ES to fail
What you can do if use the auto generate fields function but the duplicate the form but set it to not show. Then add the dynamic values and disabled to the fields - should make it quicker to build. Most IDs are increments automatically in the Wappler UI.
Just a thought for the ‘disabled’ expression, if you want to allow 0(zero) to be submitted you’ll need to make it dmx-disabled=!input.value && !input1.value=‘0’
Your solution of hiding / disabling is I believe the right one, if I don’t want any custom work, and just use native Wappler.
The problem is that when I’m trying to use the auto generate schema function from the field naming, it doesn’t construct the correct schema - which won’t allow me to create complex and working queries using this method. Patrick has already confirmed it’s not operating as expected on NodeJS - but the problem is the solution suggested by him isn’t working either, and won’t suit a completely dynamic output.
If you have any other suggestions I’d really appreciate it!