Widget instance options boolean retuning string

Thiago Pereira
Tera Contributor

Hi!!

Could someone tell me why an instance option set to boolean returns a string type on the server?

find_real_file.png

 

 

[SERVER]

console.log(options.show_header_title)
console.log(typeof options.show_header_title)

 


[Console]

true
string

2 REPLIES 2

Michael Jones -
Giga Sage

It's a bit of a quirk with Widgets but, when you are defining the option schema the "type" you select is used to determine how you display that option in the instance options, but not to define how that value is stored. I believe it doesn't matter what type you select, the value will always be stored as a string within the options object. As far as I recall it has always been that way (not something new with San Diego, just to clarify). 

I hope this helps!

If this was helpful, or correct, please be kind and mark the answer appropriately.

Michael Jones - Proud member of the GlideFast Consulting Team!

 

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

Hi Michael!

I find it's more strange than quirk. We should receive the value with the selected type...
But since SN doesn't help us with this the simplest solution I've been using (for boolen which is my current problem):

data.show_header_title = (options.show_header_title === 'true') || false;

That way I can convert to boelan as I would like it to be.