第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

范圍日期時(shí)間的辛福尼問題(窗體)

范圍日期時(shí)間的辛福尼問題(窗體)

PHP
慕虎7371278 2022-09-24 15:37:19
我不明白我的問題。如果你能給我一個想法。我有一個工作日期時(shí)間字段,但我的領(lǐng)域年份有一個奇怪的范圍(2015-2025)。我想要一個更大的范圍(例如:1960-2040)。class BookType extends AbstractType{    public function buildForm(FormBuilderInterface $builder, array $options)    {        $builder            ->add('title')            ->add('author')            ->add('publicationDate')            ->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',                    ])                ]            ])        ;    }
查看完整描述

1 回答

?
慕雪6442864

TA貢獻(xiàn)1812條經(jīng)驗(yàn) 獲得超5個贊

正如你在這里看到的 日期類型::類折射。該字段將包含用于配置選擇框行為方式的選項(xiàng)。你可以簡單地使用php的range()函數(shù)來繪制你的代碼中的年份,比如:range(1960,2040)


$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',

                    ])

                ]

            ])

        ;

    }


查看完整回答
反對 回復(fù) 2022-09-24
  • 1 回答
  • 0 關(guān)注
  • 101 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號