代码之家  ›  专栏  ›  技术社区  ›  Bas

Laravel formbuilder如何在元素中获取accept和多个属性

  •  0
  • Bas  · 技术社区  · 8 年前

    我用 http://kristijanhusak.github.io/laravel-form-builder/ 我想要一些额外的类型属性 file

    怎样才能做到这一点?

    尝试:

    ->add('image',
        'file',
        [
            'multiple' => true,
            'accept' =>"image/jpg, image/gif",
            'label' => 'Upload your image'
        ])
    

    结果:

    <input class="form-control" name="image" id="image" type="file">
    

    我想要:

    <input class="form-control" name="image" id="image" type="file" accept="image/jpg, image/gif" multiple>
    
    1 回复  |  直到 8 年前
        1
  •  0
  •   Bas    8 年前

    找到答案,使用 attr array :

    ->add('image',
        'file',
        [
            'attr' =>[
                'accept'=>"image/jpg, image/giff",
                'multiple' => true
            ],
            'label' => 'Upload your image'
        ])
    
    推荐文章