Get the value of a relationship field type
Created 7 years ago by minkyov

Hello, I am currently developing a module of my own and I am using the relationship field from which I can choose options for when an event is happening (Fall 2015, Fall 2016, Spring 2015 and so on). Everything gets saved in the database as it's supposed to but I want to get the value that I have chosen and display it on the web page. In the database the value gets saved in a column named 'title'. Also when I try to display the value of semester (Fall 2015 ...) in the table builder under the semester column I probably get the slug of the field. Why is that? Can I somehow access this value and render it on the web page?

Thank you for the cooperation!

piterden  —  7 years ago

Show how did you do it

ryanthompson  —  7 years ago

@minkyov it depends on where you are referring to on how the best way to do this would be but I'll assume the table builder / columns cause Twig / API are pretty well known (native Laravel relationships).

If you have a relation called semester and it has a title column you can include this in your table columns with entry.semester.title and it will pick up that the field is semester automatically or you can map other definition properties like header/ect.

Hope this helps!