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
I am finding the 'collection' approach to single image handling strange.
If I have a model with multiple image fields, and I want them to all only allow a single image per field, I have to make a bunch of different collections? This makes no sense to me, since I want all the image fields to draw from the same collection, but not to allow each individual field to select more than one item from the collection in question, and definitely not to delete all other items in the collection on the base media table.
This 'single' option should be set at the Field level, not implemented at the underlying spatie media collection level?
Am I just misunderstanding the docs, or is creating a bunch of separate collections the only way make a model have multiple single selection only image fields?
The text was updated successfully, but these errors were encountered:
I just found the solution to the problem I encountered too. In reality, it is not specified but you simply have to define the collection as "singleFile" in the Model corresponding to the name of the Nova form fields. It is not clearly specified in the doc, so here is my example :
``
// Model
public function registerMediaCollections(): void {
$this->addMediaCollection('singleFile')->singleFile();
$this->addMediaCollection('multipleFile');
}
I am finding the 'collection' approach to single image handling strange.
If I have a model with multiple image fields, and I want them to all only allow a single image per field, I have to make a bunch of different collections? This makes no sense to me, since I want all the image fields to draw from the same collection, but not to allow each individual field to select more than one item from the collection in question, and definitely not to delete all other items in the collection on the base
media
table.This 'single' option should be set at the Field level, not implemented at the underlying spatie media collection level?
Am I just misunderstanding the docs, or is creating a bunch of separate collections the only way make a model have multiple single selection only image fields?
The text was updated successfully, but these errors were encountered: