allowMaybe) { $choices[] = 'maybe'; } $constraints = [new Choice(['choices' => $choices])]; if ('1' === (string) $question->mandatory) { $constraints[] = new NotBlank(); } return $constraints; } public function buildField(FormBuilderInterface $builder, SurveyContentModel $question, string $fieldName = 'answer'): void { $choices = [ 'Ja' => 'yes', 'Nein' => 'no', ]; if ('1' === (string) $question->allowMaybe) { $choices['Vielleicht'] = 'maybe'; } $builder->add($fieldName, ChoiceType::class, [ 'label' => false, 'expanded' => true, 'multiple' => false, 'choices' => $choices, 'constraints' => $this->getConstraints($question), ]); } public function normalizeAnswer(mixed $value, SurveyContentModel $question): string { return mb_strtolower(trim((string) $value)); } }