Course: FOSUserBundle FTW! Tutorial
Create a new user:
a pretty flash message!
The user has been created successfully
If you don't see this, make sure you're rendering
success flash messages in
your base template: http://knpuniversity.com/screencast/symfony-forms/save-redirect-set-flash#rendering-the-flash-message
Well, that message lacks some pizzaz! How can we give it some personality? I mean, it's probably being set deep in some PHP file somewhere. Do we need to override that file?
Nope! Every string you see from this bundle is being passed through the translator. So to change text, you just need to translate it!
Back in PHPStorm, I'll close a few tabs, then press Shift+Shift and look for
FOSUserBundle.en.yml. Whenever FOSUserBundle translates something, it translates
it through a domain called
FOSUserBundle... which just means that when you translate
its strings, they'll live in a file called
Search for "The user has been created successfully". There it is! Under
Let's breathe some life into this translation! To do that, inside
create a new file:
FOSUserBundle.en.yml. Then, add the same keys:
user_created with the message:
Welcome! Now let's do some science!
|user_created: "Welcome! Now let's do some science!"|
Since this is a brand new translation file, you'll need to clear you cache for Symfony to see it:
php bin/console cache:clear
I know, you should almost never need to clear cache in the dev environment: this is one of those really rare things. When you update this translation file, you will not need to clear the cache.
Cool! Go back to
/register and repeat:
turtles... and yes! Let's do some science! Great idea!
Except, instead of science, let's customize some forms!