0
我知道像with_seconds或with_minutes选项,但即时寻找的东西停止渲染我的时间投入DateTimeType领域。现在它看起来像这样: 防止从输入显示小时 - DateTimeType
我的问题怎么可能在第二行避免这种输入? 也许与形式的主题,但我想考虑与另一种选择。
我RegistrationFormType:
<?php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
class RegistrationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('sex', ChoiceType::class, array(
'choices' => array(
'Mężczyzna' => 'Mężczyzna',
'Kobieta' => 'Kobieta'
),
'expanded'=> true,
'multiple' => false,
'required' => true
));
$builder->add('birthday_date', DateTimeType::class, array(
'placeholder' => array(
'year' => 'Year', 'month' => 'Month', 'day' => 'Day'
),
'years' => range(1960, 2017),
'with_minutes' => false,
'hours' => array()
));
$builder->add('about_me', TextareaType::class);
}
public function getParent()
{
return 'FOS\UserBundle\Form\Type\RegistrationFormType';
}
public function getBlockPrefix()
{
return 'app_user_registration';
}
}
我使用FOSUserBundle,所以这是我的表单模板现在:
{% trans_default_domain 'FOSUserBundle' %}
{{ form_start(form, {'method': 'post', 'action': path('fos_user_registration_register'), 'attr': {'class': 'fos_user_registration_register'}}) }}
{{ form_widget(form) }}
<div>
<input type="submit" value="{{ 'registration.submit'|trans }}" />
</div>
{{ form_end(form) }}
感谢你提前!