Search code examples
phpsymfonyvichuploaderbundle

cant translate name UploadButton in my Form


i got a problem in my form. Im translating all my fields with message.yml and it works. But i have also a upload button from VichUploaderBundle in it. I can translate the label, but when im testing it, the label is in english, but the button is in german.

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('id', TextType::class, array('disabled' => true))
        ->add('title',TextType::class, array('label' => 'edit.title'))
        ->add('body', TextareaType::class, array('label' => 'edit.body'))
        ->add('date', DateType::class, array('disabled' => true, 'label' => 'edit.date'))
        ->add('tags', EntityType::class, array(
            'class' => 'AppBundle:Tag',
            'choice_label' => 'getTitle',
            'multiple'=> true,
            'expanded'=> true))
        ->add(
            'technology',
            EntityType::class,
            array(
                'class' => 'AppBundle\Entity\Technology',
                'choice_label' => 'getTitle',
                'group_by' => 'parent.getTitle',
                'query_builder' => function (EntityRepository $er) {
                    return $er->createQueryBuilder('t')
                        ->where('t.parent IS NOT NULL')
                        ->andWhere('SIZE(t.children) <= 0');
                }
            ))
        ->add('imageFile', VichImageType::class, array(
            'required'      => false,
            'allow_delete'  => true,
            'download_link' => true,
            'label'     => 'edit.image_file',
            ))
    ;
}

I dont know how to translate the button.


Solution

  • You are only creating a html file input.

    This input does not have some label attribute.

    <input type="file" name="imageFile"/>
    

    -> the button label is set by your browser (which seems to be in german).

    You can try to change it with CSS/JS