New topic Closed topic
avatar image
1
How to transform an object in to url variables
By Created , last editted

Hi there,

I would like to create an GET endpoint on which the variables of an object are already filled in, in the inputs using input variables.

I'm am trying to build an url via a text expression. The URL is based on a model and has to be something like:

domain.com/form?object[first_name]=Betty&object[last_name]=Blocks


I'd like to create an expression like:

"domain.com/form?" + serialize(var:object)

Serialize is a JS function, but doesn't seem to exist in Betty Blocks, according to the documentation. 


My current guess is:

"domain.com/form?object[first_name]=" + var:object.first_name +
"&object[last_name]=" + var:object.last_name

But if the property names change, this expression will have to be changed manually too, which kinda strikes against the use of an expression.


Is there a nicer way to do this?


Hi there,

I would like to create an GET endpoint on which the variables of an object are already filled in, in the inputs using input variables.

I'm am trying to build an url via a text expression. The URL is based on a model and has to be something like:

domain.com/form?object[first_name]=Betty&object[last_name]=Blocks


I'd like to create an expression like:

"domain.com/form?" + serialize(var:object)

Serialize is a JS function, but doesn't seem to exist in Betty Blocks, according to the documentation. 


My current guess is:

"domain.com/form?object[first_name]=" + var:object.first_name +
"&object[last_name]=" + var:object.last_name

But if the property names change, this expression will have to be changed manually too, which kinda strikes against the use of an expression.


Is there a nicer way to do this?

Answers
Sort by:

This topic is closed.