protected buildTextType ( Symfony\Component\Form\FormBuilderInterface $builder, array $options, string $fieldName, Dumplie\Metadata\Schema\FieldDefinition $definition ) | ||
$builder | Symfony\Component\Form\FormBuilderInterface | |
$options | array | |
$fieldName | string | |
$definition | Dumplie\Metadata\Schema\FieldDefinition |
protected function buildTextType(FormBuilderInterface $builder, array $options, string $fieldName, FieldDefinition $definition)
{
$typeOptions = $options['type_options'];
$typeForms = $options['type_forms'];
$isRequired = !$definition->isNullable();
$options = ['required' => $isRequired];
if ($isRequired) {
$options['constraints'] = [new NotBlank()];
}
$builder->add($fieldName, array_key_exists($fieldName, $typeForms) ? $typeForms[$fieldName] : TextType::class, array_key_exists($fieldName, $typeOptions) ? array_merge($options, $typeOptions[$fieldName]) : $options);
}