Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Isotope\Model\Attribute;

use Contao\StringUtil;
use Isotope\Interfaces\IsotopeAttributeForVariants;

/**
Expand Down Expand Up @@ -42,7 +43,13 @@ public function saveToDCA(array &$arrData)
parent::saveToDCA($arrData);

if ('attribute' === $this->optionsSource) {
$arrData['fields'][$this->field_name]['sql'] = "varchar(64) NOT NULL default ''";
$length = 64;

array_walk(StringUtil::deserialize($this->options, true), function($option) use (&$length) {
$length = max(ceil(mb_strlen($option['value'] ?? '') / 64) * 64, $length);
});

$arrData['fields'][$this->field_name]['sql'] = "varchar($length) NOT NULL default ''";
} else {
$arrData['fields'][$this->field_name]['sql'] = 'int(10) NOT NULL default 0';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Isotope\Model\Attribute;

use Contao\StringUtil;
use Isotope\Interfaces\IsotopeAttributeForVariants;

/**
Expand Down Expand Up @@ -51,7 +52,13 @@ public function saveToDCA(array &$arrData)
$arrData['fields'][$this->field_name]['sql'] = 'blob NULL';
} else {
if ('attribute' === $this->optionsSource) {
$arrData['fields'][$this->field_name]['sql'] = "varchar(64) NOT NULL default ''";
$length = 64;

array_walk(StringUtil::deserialize($this->options, true), function($option) use (&$length) {
$length = max(ceil(mb_strlen($option['value'] ?? '') / 64) * 64, $length);
});

$arrData['fields'][$this->field_name]['sql'] = "varchar($length) NOT NULL default ''";
} else {
$arrData['fields'][$this->field_name]['sql'] = 'int(10) NOT NULL default 0';
}
Expand Down