Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 范围日期时间(表单)的Symfony问题_Php_Symfony_Symfony4 - Fatal编程技术网

Php 范围日期时间(表单)的Symfony问题

Php 范围日期时间(表单)的Symfony问题,php,symfony,symfony4,Php,Symfony,Symfony4,我不明白我的问题。 如果你能给我一个想法。 我有一个dateTime字段,但 我的野外工作年限有一个奇怪的范围(2015-2025年)。 我想要一个更大的范围(例如:1960-2040) 正如你在这里看到的。该字段将具有配置选择框行为方式的选项。您可以简单地使用php的range()函数在代码中绘制年份,如:range(1960、2040) 在代码中,只需使用: class BookType extends AbstractType { public function buildForm

我不明白我的问题。 如果你能给我一个想法。 我有一个dateTime字段,但 我的野外工作年限有一个奇怪的范围(2015-2025年)。 我想要一个更大的范围(例如:1960-2040)

正如你在这里看到的。该字段将具有配置选择框行为方式的选项。您可以简单地使用php的range()函数在代码中绘制年份,如:range(1960、2040)

在代码中,只需使用:

class BookType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('title')
            ->add('author')
            ->add('publicationDate', DateType::Class , [
                'years' => range(1960, date('Y')+20) // Change As eper your requirements
            ])
            ->add('format')
            ->add('language')
            ->add('user')
            ->add('excelFile', FileType::class,[
                'label' => 'Fichier excel (xls/xlsx file)',
                'mapped' => false,
                'required' => false,
                'constraints' => [
                    new File([
                        'maxSize' => '1024k',
                        'mimeTypes' => [
                            'application/vnd.ms-excel',
                            'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
                        ],
                        'mimeTypesMessage' => 'Please upload a valid xls/xlsx document',
                    ])
                ]
            ])
        ;
    }
$builder->add('field', DateType::Class , [
    'years' => range(date('Y')-50, date('Y')+50) // Lists 50 Years Before and After
]);
class BookType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('title')
            ->add('author')
            ->add('publicationDate', DateType::Class , [
                'years' => range(1960, date('Y')+20) // Change As eper your requirements
            ])
            ->add('format')
            ->add('language')
            ->add('user')
            ->add('excelFile', FileType::class,[
                'label' => 'Fichier excel (xls/xlsx file)',
                'mapped' => false,
                'required' => false,
                'constraints' => [
                    new File([
                        'maxSize' => '1024k',
                        'mimeTypes' => [
                            'application/vnd.ms-excel',
                            'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
                        ],
                        'mimeTypesMessage' => 'Please upload a valid xls/xlsx document',
                    ])
                ]
            ])
        ;
    }