Symfony2 forms interpret blank strings as nulls

前端 未结 7 2307
温柔的废话
温柔的废话 2021-02-19 09:12

I have a Symfony2 form with a variety of fields, including one optional text field called recap.

This recap field saves perfectly when there\'s

7条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-19 09:33

    In Forms, you can do:

    $builder
    ->add('optionalField', TextType::class, ['required'=>false, 'empty_data'=>''])
    

提交回复
热议问题