首页 > 解决方案 > FileType picker button

问题描述

This is really basic...but I don't find where the documentation allow the modification

I've a form with a FileType.

It looks like this:

Label ------File Space-------- Browse Button

I've been able to change the label text. But I can't find how to specify the Browse button texte.

    $form = $this->createFormBuilder()
        ->add('importer', FileType::class, ['label' => 'Import CSV'])
        ->add('import', SubmitType::class, ['label' => 'Import'])
        ->getForm();

When I look into the FileType options I can't find what I'm looking for.

Thanks.

标签: symfony

解决方案


我认为您可以尝试使用这样的attr选项:

$form = $this->createFormBuilder()
        ->add('importer', FileType::class, [
              'label' => 'Import CSV',
              'attr' => ['placeholder' => 'Custom button name'],
         ])
        ->add('import', SubmitType::class, ['label' => 'Import'])
        ->getForm();

推荐阅读