set attributes and save instead of creating via mass assignment to play nicer with various features and avoid requiring fillable properties to be set

This commit is contained in:
Luke Towers 2020-04-29 16:48:46 -06:00
parent 29740ea1e8
commit fc8e258c6d
1 changed files with 3 additions and 1 deletions

View File

@ -137,7 +137,9 @@ class TagList extends FormWidgetBase
$newTags = $this->customTags ? array_diff($names, $existingTags) : [];
foreach ($newTags as $newTag) {
$newModel = $relationModel::create([$this->nameFrom => $newTag]);
$newModel = new $relationModel;
$newModel->{$this->nameFrom} = $newTag;
$newModel->save();
$existingTags[$newModel->getKey()] = $newTag;
}