如何更改Symfony2 FOSUser寄存器窗体错误消息?

时间:2016-06-19 05:59:03

标签: forms validation symfony fosuserbundle

我已经定制了我的register_content.html.twig

            <form class="form-horizontal" action="{{ path('fos_user_registration_register') }}" {{ form_enctype(form) }} method="POST">
                <div id="fos_user_registration_form">
                <div class="form-group">
                    <div class="col-sm-10">
                        {{ form_widget(form.username, { 'attr': {'class': 'form-control', 'placeholder': 'Pick a username' } }) }}
                        {{ form_errors(form.username) }}
                    </div>
                </div> ...

现在,当我收到错误时,那些错误就像那样

fos_user.username.already_used
fos_user.email.already_used
fos_user.password.mismatch

我只想更改这些消息,有人可以帮助我吗?

1 个答案:

答案 0 :(得分:5)

启用翻译服务后,例如,

应用\设置\ config.yml:

var sheet = SpreadsheetApp.getActive();
 ScriptApp.newTrigger("myFunction")
   .forSpreadsheet(sheet)
   .onChange()
   .create();

将适当的FOSUserBundle。{locale} .yml从framework: translator: { fallback: "%locale%" } 复制到...vendor/friendsofsymfony/userbundle/Resources/translations。在复制的文件中,更改

的消息
...app/Resources/translations