You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AsgardCMS Version: 3.5.0
AsgardCMS Blog Module Version: 3.0.1
Situation
Brand new Install of AsgardCMS with asgardcms/blog module installed.
Error
When creating a blog post in the Blog Module, if I do not specify a tag I get an error saying Argument 1 is not an Array from the setTags() method of the TaggableTrait.
As a note, the third screenshot was taken at a later time than the other two. As the original did not expand the data array in question. Thus, the data in the two screenshots don't match, but that isn't important to the original issue. Just didn't want someone noticing and trying to deduce why they were different.
Synopsis
There are two array_diff calls in the TaggableTrait's setTags method that expect the first parameter to be an array. In my instance, the EloquentPostRepository makes the setTags call on line 64. That line is expecting a the post data (though this appears to be modified before reaching this method) to contain a 'tags' index. And it does not appear that one is present.
Summary
Hopefully I'm providing enough information. I'm brand new to AsgardCMS. If I've missed a something in setup or am the root of this error, can you provide instruction as to what I did wrong? Thanks.
The text was updated successfully, but these errors were encountered:
You can have this modifying the function as follow:
``
/**
* {@inheritdoc}
*/
public function setTags($tags, $type = 'slug')
{
if (is_array($tags) && count($tags) > 0) {
// Get the current entity tags
$entityTags = $this->tags->pluck($type)->all();
// Prepare the tags to be added and removed
$tagsToAdd = array_diff($tags, $entityTags);
$tagsToDel = array_diff($entityTags, $tags);
// Detach the tags
if (count($tagsToDel) > 0) {
$this->untag($tagsToDel);
}
// Attach the tags
if (count($tagsToAdd) > 0) {
$this->tag($tagsToAdd);
}
}
return true;
}
``
Haven't check if this breaks anything else... As @F2KLabs I'm new to AsgardCMS code... Should I send a PR for this?
Ran into same issue. I used tranfuga's suggestion and it is doing the trick. Would be good to know if that's a supported workaround (i.e. what, if any, are the hidden drawbacks of allowing blank tags?)
AsgardCMS Version: 3.5.0
AsgardCMS Blog Module Version: 3.0.1
Situation
Brand new Install of AsgardCMS with asgardcms/blog module installed.
Error
When creating a blog post in the Blog Module, if I do not specify a tag I get an error saying Argument 1 is not an Array from the setTags() method of the TaggableTrait.
Synopsis
There are two array_diff calls in the TaggableTrait's setTags method that expect the first parameter to be an array. In my instance, the EloquentPostRepository makes the setTags call on line 64. That line is expecting a the post data (though this appears to be modified before reaching this method) to contain a 'tags' index. And it does not appear that one is present.
Summary
Hopefully I'm providing enough information. I'm brand new to AsgardCMS. If I've missed a something in setup or am the root of this error, can you provide instruction as to what I did wrong? Thanks.
The text was updated successfully, but these errors were encountered: