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

Mohsin
Mohsin

I have make a fork of the oc-test-plugin. I have added 2 models called Place and Facility and created a controller for place. For now I’ve allowed 3 types of places in the type dropdown (Restaurant, Gas Station & ATM). My goal is to allows filtering of the facilities depending on the type selected on the place.

Initially I create some facilities such as washroom, 24 Hours, etc. For washroom I select restaurant and gas station only because it won’t make sense for this facility to ever be in an ATM (or assume that’s the case). For 24-hours I select gas station and Atm. Lets assume all restaurants close sometime so none of them are 24-hours.

I need some filtering to happen during creation of a place. When I select the type from the place and select Add Facilities I need only to show the facilities that are applicable to that type and the others should not appear. I’ve been trying to figure how to make this work for couple of hours now--some help would be appreciated. Thanks!

Last updated

Cpt.Meatball
Cpt.Meatball

See this link. I think it should cover the basics of what you are trying to accomplish.

Mohsin
Mohsin

I had already gone thro that documentation to write the code so far. Unfortunately it doesn’t seem to work for relationController. I’m guessing this might be yet to be added to OctoberCMS or there is another way to do it with some more code?

Cpt.Meatball
Cpt.Meatball

Ehm.. two ideas pop to mind:

Drop the relation controller and just populate the dropdown with items from given model. So officially there isn't a relation, but deep down you know it has. At least, if the relation controller is be the problem.

or

Write soms javascript code filter out the dropdowns, although I'm not really sure this is a foolproof way of doing this.

1-4 of 4

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