Skip to content

Commit

Permalink
Create AbstractTranslatedEnumSettingType.php
Browse files Browse the repository at this point in the history
  • Loading branch information
hgabka authored Feb 27, 2023
1 parent caee281 commit c843fc3
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/Model/AbstractTranslatedEnumSettingType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Hgabka\SettingsBundle\Model;

use Hgabka\UtilsBundle\Form\Type\TranslatedEnumType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;

class AbstractTranslatedEnumSettingType extends AbstractSettingType
{
protected ?string $enumClass = null;

public function getFormType(): string
{
return TranslatedEnumType::class;
}

public function getFormTypeOptions(): array
{
$options = [
'class' => $this->enumClass,
];

if (!empty(($choiceOptions = $this->getChoiceOptions()))) {
$options = array_merge($options, $choiceOptions);
}

return $options;
}

protected function getChoiceOptions(): array
{
return [
'placeholder' => '',
];
}
}

0 comments on commit c843fc3

Please sign in to comment.