chance
chance

Reputation: 315

Symfony2 - Edit label display name in form

I need to capitalize the second word in the label name, how do I edit the label name in the form? (e.g., 'Email Address' and not 'Email address')

I've tried setting it in the form creation as follows:

->add('Email_Address', 'email', array(
    'attr' => array(
        'label' => 'Email Address',
        'placeholder' => ''
    )
))

But this only capitalizes the first letter 'E'mail and not 'A'ddress. I've looked in the form_div_layout.html.twig file but didn't see anything to edit this, this probably something simple I'm overlooking.

Can someone show me how to do this?

Upvotes: 2

Views: 246

Answers (2)

ghanbari
ghanbari

Reputation: 1629

->add('Email_Address', 'email', array(
    'label' => 'Email Address',
    'attr' => array(
        'placeholder' => '',
    ),
))

Upvotes: 4

webdev
webdev

Reputation: 761

This should work, move 'label' => '...' before 'attr'.

->add('email_address', 'email', array(
    'label' => 'Email Address',
    'attr' => array(
//      'label' => 'Email Address',
        'placeholder' => ''
    )
))

Upvotes: 3

Related Questions