Chaos
Chaos

Reputation: 405

Umlauts not beeing displayed properly in symfony2

Im having the following problem. If I try to use this code

$form = $this->createFormBuilder()
        ->add('code', 'integer', array(
            'attr' => array('class' => 'login-input')
        ))
        ->add('einlösen', 'submit', array(
            'attr' => array('class' => 'login-submit')
        ))
        ->getForm();

my browser doesnt show the ö in einlösen. If i remove the class attr it works. I thought this might be a css issue but the problem seems to be with symfony, since there is no matter what class I use the ö always gets mangled.

Another thing I realized is that if I do a cache clear the ö is there but as soon as i press the button once and reload the page its not showing up properly again.

Upvotes: 0

Views: 373

Answers (1)

Rob
Rob

Reputation: 5481

Try to use the label option:

$this->createFormBuilder()
    ->add('submit', 'submit', array(
        'label' => 'einlösen',
        'attr' => array('class' => 'login-submit')
    ))

As an alternative you can set/overwrite the label in twig:

{{ form_widget(form.submit, { 'label': 'einlösen' }) }}

Upvotes: 1

Related Questions