true, 'targetClass' => Producer::class, 'targetAttribute' => ['id_producer' => 'id']], [['name', 'string', 'text'], 'string'], [['name','string'], 'string', 'max' => 255], [['date'], 'date', 'format' => 'php:Y-m-d'], [['integer'], 'integer'], [['float', 'double'], 'number'], [['boolean'], 'boolean'], [['name'], 'unique'], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => 'ID', 'id_producer' => 'Producteur', 'name' => 'Nom', ]; } public function getValue() { $settingDetail = $this->getSettingDetail(); $type = $settingDetail->getType(); return $this->$type; } public function getSettingDetail() { return SettingDefinition::getInstance()->getSettingDetailByName($this->name); } public function getProducer() { return $this->hasOne(Producer::class, ['id' => 'id_producer']); } public function populateProducer(Producer $producer = null): void { if($producer) { $this->populateFieldObject('id_producer', 'producer', $producer); } } }