protected $_adminType = 'dropzone_media';
protected $_viewNamespace = CubistBackpackServiceProvider::NAMESPACE . '::fields';
protected $_databaseType = 'text';
- protected $_thumbCollection = 'backpack_thumb';
+ protected $_thumbConversion = 'backpack_thumb';
+ protected $_nameAsCollection = false;
protected $_maxFiles = 1;
public function getDefaultAttributes()
{
$collection = '_TBD_';
return array_merge(parent::getDefaultAttributes(), [
+ 'name_as_collection' => $this->_nameAsCollection,
'form' => 'update',
'mime_types' => $this->_mimeTypes,
'collection' => $collection,
- 'thumb_collection' => $this->_thumbCollection,
+ 'thumb_conversion' => $this->_thumbConversion,
'default' => $collection,
'options' =>
[
]);
}
+ protected function _postSetAttributes()
+ {
+ parent::_postSetAttributes();
+ if ($this->getAttribute('name_as_collection')) {
+ $name = $this->getAttribute('name');
+ $this->setAttribute('collection', $name);
+ $this->setAttribute('default', $name);
+ }
+ }
+
protected function _getAttributesAliases()
{
return array_merge(parent::_getAttributesAliases(), [
$collection = $this->getAttribute($fieldname);
$save = false;
if (!$collection) {
- $collection = substr(hash('sha256', uniqid($fieldname, true)), 0, 10);
+ $field = $this->getField($fieldname);
+ if ($field->getAttribute('name_as_collection', false)) {
+ $collection = $fieldname;
+ } else {
+ $collection = substr(hash('sha256', uniqid($fieldname, true)), 0, 10);
+ }
$this->setAttribute($fieldname, $collection);
$save = true;
}