Skip to content

Commit 5500509

Browse files
committed
feat(title): add constraint on option
1 parent b492b88 commit 5500509

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Form/Type/UiElement/TitleType.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ class TitleType extends AbstractType
3030
*/
3131
public function buildForm(FormBuilderInterface $builder, array $options): void
3232
{
33+
$requiredTitle = $options['required_title'] ?? false;
3334
$builder
3435
->add('content', TextType::class, [
35-
'required' => $options['required_title'] ?? false,
36+
'required' => $requiredTitle,
3637
'label' => 'monsieurbiz_richeditor_plugin.ui_element.monsieurbiz.title.field.content',
37-
'constraints' => [
38+
'constraints' => $requiredTitle ? [
3839
new Assert\NotBlank([]),
39-
],
40+
] : [],
4041
])
4142
->add('text_size', TextSizeType::class, [
4243
'required' => false,

0 commit comments

Comments
 (0)