1

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.

Meister Ho
  • 47
  • 6

2 Answers2

0

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

Community
  • 1
  • 1
Alsatian
  • 3,086
  • 4
  • 25
  • 40
0

These text is defined by the browser and not by PHP or Symfony. You will also notice that this widget will be displayed differently in different browsers and on different operating systems. There is also no possibility to change the design of the widget. Most CSS properties won't have an effect on .

The only thing that you could do is to implement a custom JavaScript uploader, but that will probably only work in modern browsers.

I have not never done this, but a quick Google search brought up http://www.queness.com/post/11434/7-javascript-ajax-file-upload-plugins that features few JavaScript plugins to do this.

Jigar Pancholi
  • 1,209
  • 1
  • 8
  • 25