Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set field value a a variable depending on another fields value #20

Closed
laahs opened this issue Jun 12, 2016 · 4 comments
Closed

Set field value a a variable depending on another fields value #20

laahs opened this issue Jun 12, 2016 · 4 comments

Comments

@laahs
Copy link

laahs commented Jun 12, 2016

For example on a schema I could have fields such as "city"=city and "business-name"=the_name. And use those to build a url friendly id and access the page via domain.com/business/the_name_city.

What would be the easiest way to do it?

I don't really understand how to access the data in it's "storable" version once compiled from the schema ...

@rs
Copy link
Owner

rs commented Jun 15, 2016

At resource level you can bind the Insert and Update events to compute this field. See Hooks for more info.

@laahs
Copy link
Author

laahs commented Jun 15, 2016

Ok for example i should use inserteventhandlerfunc which has an oninsert method taking a context and a payload (map[string]interface) and here the payload is the map of field names/values of my resources, defined via the schema. Right?

So I can access their "final" values and manipulate them before sending to the storer. Is that the procedure ? (Sorry to bother you but I'm on my phone so i can not try the procedure instead of asking you to confirm that this is what you meant)

@rs
Copy link
Owner

rs commented Jun 15, 2016

That's exactly the idea yes.

@laahs
Copy link
Author

laahs commented Jun 15, 2016

Okay perfect, I'll try it. I was missing the part where I have access to the final representation of the data, as transfered to the storer ... therefor was I locked in the "schema" phase with init/update functions that can be attached to the field, but fields values are isolated in the schema ... this was where I got stuck. Thank you for your response :)

Have you delivered a ffew projects using rest-layer yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants