stored object: add has_title option to form type of StoredObject

This commit is contained in:
nobohan 2022-05-25 17:14:21 +02:00
parent dea554ced4
commit e8cf7ae8e1
2 changed files with 11 additions and 0 deletions

View File

@ -313,6 +313,7 @@ class ActivityType extends AbstractType
'button_add_label' => 'activity.Insert a document',
'button_remove_label' => 'activity.Remove a document',
'empty_collection_explain' => 'No documents',
'entry_options' => ['has_title' => true],
]);
}

View File

@ -17,6 +17,7 @@ use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@ -64,12 +65,21 @@ class StoredObjectType extends AbstractType
[$this, 'transformObject'],
[$this, 'reverseTransformObject']
));
if ($options['has_title']) {
$builder
->add('title', TextType::class);
}
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setDefault('data_class', StoredObject::class);
$resolver
->setDefault('has_title', false)
->addAllowedValues('has_title', [true, false]);
}
public function getBlockPrefix()