I have a TagTable with a “through-table” called TagsRelations. TagsTable holds all tags (title and type), TagsRelations the primary-keys of the subjects (tag_id, subject_id) and the section that describes, what has been tagged (a file, an article etc…). So TagsRelations.section must not be null.
When I add a new article and select two tags, the tags will be recognized but the tagsrelation with “section” (e.g. “articles” in that case) will not be filled. How can I say the view or the controller (or maybe even the table), that the “section”-column should be filled with “articles”?
My form in add.ctp looks like this (regarding the tags)
echo $this->Form->control('tags._ids', [ 'type' => 'select', 'multiple' => true, 'options' => $tags, ]);
I also tried to add in the controller a foreach-loop that adds a “_joinData”-array to the post-data.
In short: How to add joinData using a select-control in a belongsToMany-Relationship (or how do it otherwise), when we don’t know before, how many items (= tags) will be selected.
Thanks in advance.