gpt4 book ai didi

php - Symfony2选择字段必须为empty_value

转载 作者:行者123 更新时间:2023-12-01 03:40:41 25 4
gpt4 key购买 nike

我的注册表中有问题。我有一个选择字段,用于提交表单。在我的表格中,我有:

->add('playerPosition', 'choice', array(
'choices' => array('Spelverdeler' => 'Spelverdeler', 'Receptie/Hoek' => 'Receptie/Hoek', 'Libero' => 'Libero', 'Midden' => 'Midden', 'Opposite' => 'Opposite', 'All-round' => 'All-round'),
'label' => 'Spelerspositie*',
'empty_value' => 'Kies uw positie.',
'required' => true
))


并且当表单显示值“ Kies uw positie”时。被选中。但是,当您提交时,我没有得到它所必需的错误。 (因为选择了值'Kies uw positie。',但这只是空值..)

我也在选择列表中使用selected,如下所示:

$('#register_player_playerPosition').chosen();


那么,该怎么办才能将空值视为一个值呢?我需要有一个不是有效值的“空值” ...因此,用户被迫选择一个选项。

最佳答案

您应该使用“ placeholder”而不是“ empty_value

->add('playerPosition', 'choice', array(
'choices' => array('Spelverdeler' => 'Spelverdeler', 'Receptie/Hoek' => 'Receptie/Hoek', 'Libero' => 'Libero', 'Midden' => 'Midden', 'Opposite' => 'Opposite', 'All-round' => 'All-round'),
'label' => 'Spelerspositie*',
'placeholder' => 'Kies uw positie.',
'required' => true
))

关于php - Symfony2选择字段必须为empty_value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21230522/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com