This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Vannut
Vannut

For starters: Sorry for the obscure title :) But I did not have a clue how to word it in 1 sentence :)

I'm building a plugin which can display/organize some activities. And those activities can have 1 or more prices attached to it. People can subscribe to these prices in a later stage of the development of this plugin. But that's something for later.

As we have two entities, I created two models: Activity and Price which are defined as in this gist, with the migrations: https://gist.github.com/vannut/d7629a3860fd64283e76ef4ce9643247

In the update-page from the activity controller I want to add a section (or tab) in which I can enter new and view existing attached prices.

What is the best approach to do this? Using type:relation in \models\activity\fields.yaml does not result in the right result. Using this field type results in all prices being displayed with a checkbox. I only want to display the 'attached' prices with a delete option; and the ability to create a new price.

Any suggestions?

Last updated

pratyushpundir6424
pratyushpundir6424

You might want to use the RelationBehavior. Official documentation is over here - http://octobercms.com/docs/backend/relations#introduction

For a more real world example, you can also take a look at this plugin I had built but the project eventually was scrapped by the client: https://github.com/pratyushpundir/OctoberCMSAndVueJS/tree/master/plugins/sublimearts/dealerstore

Vannut
Vannut

That's exactly what I searched for.! Thank you.

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.