Currently the chooser allows you to filter on linked fields. That can be useful in many situations. What I'd like to add is the ability to pass parameters to the Chooser that can determine which site you're on. Say you have three site objects in your Wagtail instance. a.com, b.com, and c.com. You have a model "Newsletter" that has a foreign key to one of these sites. So for each site you have a number of newsletters that are linked to that site. Now when the user is creating a new page, or editing one, I'd like to only show them newsletters that are relevant to the site for which they are currently creating a page. I've already found a mechanism that allows us to easily achieve this. The form action of a page builder is either a URL to add a new page, or to edit an existing one. If we pass this ID to the chooser viewset, we can find the corresponding page for that ID, and see which site it is connected to.
Currently, looking at the linked fields implementation, the only functionality that this package provides is the part that fetches the value from the field and passes it to the chooser. Hence, this could be achieved in a similar fashion. Aside from the "selector" and "match" lookup types, we could add a "site" lookup type, that returns the id of the page you're trying to edit, if this ID already exists, or the id of the parent page if it's a new page. The question here would be if this could be considered a "linked field" or if this would require some new mixin, like a LinkedSiteMixin for example.
Currently the chooser allows you to filter on linked fields. That can be useful in many situations. What I'd like to add is the ability to pass parameters to the Chooser that can determine which site you're on. Say you have three site objects in your Wagtail instance. a.com, b.com, and c.com. You have a model "Newsletter" that has a foreign key to one of these sites. So for each site you have a number of newsletters that are linked to that site. Now when the user is creating a new page, or editing one, I'd like to only show them newsletters that are relevant to the site for which they are currently creating a page. I've already found a mechanism that allows us to easily achieve this. The form action of a page builder is either a URL to add a new page, or to edit an existing one. If we pass this ID to the chooser viewset, we can find the corresponding page for that ID, and see which site it is connected to.
Currently, looking at the linked fields implementation, the only functionality that this package provides is the part that fetches the value from the field and passes it to the chooser. Hence, this could be achieved in a similar fashion. Aside from the "selector" and "match" lookup types, we could add a "site" lookup type, that returns the id of the page you're trying to edit, if this ID already exists, or the id of the parent page if it's a new page. The question here would be if this could be considered a "linked field" or if this would require some new mixin, like a LinkedSiteMixin for example.