symfony - Symfony2 form: no empty choice -


building symfony2 form choices, there option "empty value", set text related empty choice.

however, want set choice field mandatory, empty value should displayed no choosen. using empty or null constraints, there no error when user send "" value. how should done?

you can add notblank() validation constraint appropriate property in form's underlying entity.

how depends on whether using annotations or yaml validation definitions.

there information validator here:

http://symfony.com/doc/current/reference/constraints/notblank.html

hope helps :)


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -