문제

I have this code, but it doesn't work:

$builder->add('name','text',array(
    'label'  => 'Due Date',
));

the problem i have in fosuserbundle, i have overring form

<?php
namespace Acme\UserBundle\Form\Type;

use Symfony\Component\Form\FormBuilder;
use FOS\UserBundle\Form\Type\RegistrationFormType as BaseType;

class RegistrationFormType extends BaseType
{
    public function buildForm(FormBuilder $builder, array $options)
    {


        // add your custom field
        $builder->add('name','text',array(
    'label'  => 'Due Date',
));
        parent::buildForm($builder, $options);
    }

    public function getName()
    {
        return 'acme_user_registration';
    }
}

but not work, not give me any error and set the label "fos_user_registration_form_name"

도움이 되었습니까?

해결책

You see label as fos_user_registration_form_name, because FOSUserBundle uses translations files to translate all texts in it.

You have to add your translations to file called like Resources/translations/FOSUserBundle.nb.yml (example for norwegian) or you can modify translations file coming with the bundle (copying it to Acme\UserBundle is a better way).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top