Currently I have a field that extends BaseRelationField, and 2 types of elements. I want the field on elements A to be able to select from elements B.
So far the field itself works, which I tested by registering it and adding it to an entry. It shows elements B as options and stores it in the relations table.
So far so good.
But I don't want to add this field to an entry, but to elements A. My current attempts revolved around using Craft::$app->fields->createField() and Craft::$app->fields->saveField() to create the field (which also gives it an id) since Craft::$app->getRelations()->saveRelations() requires the field to have an id (which makes sense to me). But this means my field will show up in the settings/fields in the cp. Also using this method, I don't know how to properly retrieve the values to fill the index page of the element and the edit page.
Is there some way to add the field without adding it to the 'normal' part of the cp while being able to use the relations table or am I going at this completely wrong? And also how to retrieve the stored data in the most convenient way?