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) }}
感謝你提前!