Passing arrays and objects to custom module

Hopefully a quick question - I've looked but couldn't see the answer anywhere here or in the docs.

I'm writing a custom module (Node) and I need to pass arrays and objects to it. How do I enter that in the hjson so it shows in the UI?

I mean as a variable under Properties. E.g. for a text input, it would be:

{name: 'input_name', optionName: 'input_name', title: 'Some title', type: 'text', required: true, defaultValue: ' ', help: 'Some help text', serverDataBindings: true, allowPaste: true}

So I'm looking for the equivalent for an array or an object. I've tried:

{name: 'array_name', optionName: 'array_name', title: 'Array title', type: 'array', required: true, defaultValue: , help: 'A array to pass.', serverDataBindings: true, allowPaste: true}

The module expects the input (when required is set to true) but it doesn't appear in the UI with all the text inputs. So how do I pass the array?

Thanks

There is no "special" type for array to pass to custom module.

serverDataBindings: true

Just make sure you have serverDataBindings: true - and from Wappler UI just select an array to pass your custom extension module. (SQL Query output for instance).

Ah - I was overthinking it. I guess it just gets passed as a string. Switched it back to text and it worked perfectly.

Thanks

Do you know how I can pass a db query result as input to a custom module? How do I define it in hjson and read in the js file?

TIA

You simply use an hjson text input with serverbindings:true and select the the query.

Then within the .js,you need to "parse" the text input to get the values (search forum for parseRequired() and parseOptional)
Have you viewed my youtube series on custom extensions?

1 Like

I have watched Wappler's YT series in the past and have build a few, probably will have to watch it again for some tidbits I haven't used and might be there.

Thank you for your feedback.

I have updated and can now parse the results based on your inputs above and here

This series should be a big help for you.

https://youtube.com/playlist?list=PLUjqTJN3byC9xeGDoHiAdJwIJT-zMp8aS&si=aaKzczQ7Cc1Rqn6S

1 Like

Thank you so much! I have been trough it already in the past and will give it another sweep.

I love the modules feature!