class SiteVariant extends SelectFromArray
{
+ protected $_allowNull = false;
+
public function __construct($attributes)
{
$variants = App::getVariants();
if (count($variants) === 0) {
+ $this->_viewNamespace = 'crud::fields';
$attributes['column'] = false;
- $this->_adminType = 'hidden';
- $this->_options = ['default' => 'default'];
+ $attributes['type'] = 'hidden';
+ $attributes['options'] = ['default' => 'default'];
+ $attributes['default'] = 'default';
} else {
- $this->_options = array_combine($variants, $variants);
+ $attributes['options'] = array_combine($variants, $variants);
+ $attributes['default'] = array_values($attributes['options']);
}
parent::__construct($attributes);
}
'allows_null' => false,
'options' => $options,
'tab' => $tab]);
+
+ $this->addField(['name' => 'variant',
+ 'type' => 'SiteVariantMultiple',
+ 'label' => 'Variante du site',
+ 'translatable' => false,
+ 'tab' => $tab]);
}
protected function _internalSearch()