Improve user experience for creation of document categories with select field for document class

This commit is contained in:
2024-11-05 15:28:11 +01:00
parent 2573c32160
commit df30ca2c4f
3 changed files with 18 additions and 3 deletions

View File

@@ -17,15 +17,25 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Contracts\Translation\TranslatorInterface;
class DocumentCategoryType extends AbstractType
{
public function __construct(private readonly TranslatorInterface $translator)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$bundles = [
'chill-doc-store' => 'chill-doc-store',
];
$documentClasses = [
$this->translator->trans('Accompanying period document') => "Chill\DocStoreBundle\Entity\AccompanyingCourseDocument",
$this->translator->trans('Person document') => "Chill\DocStoreBundle\Entity\PersonDocument",
];
$builder
->add('bundleId', ChoiceType::class, [
'choices' => $bundles,
@@ -34,7 +44,10 @@ class DocumentCategoryType extends AbstractType
->add('idInsideBundle', null, [
'disabled' => true,
])
->add('documentClass', null, [
->add('documentClass', ChoiceType::class, [
'choices' => $documentClasses,
'expanded' => false,
'required' => true,
'disabled' => false,
])
->add('name', TranslatableStringFormType::class);