vimuth
vimuth

Reputation: 5612

Change default flash messages in Sonata admin

I need to change default success message when we get after creating an item into my own success message. After few digging I found out how to create new flash messages but change existing messages is still a mystery to me.

This is my config.yml file

#app/config/config.yml
sonata_core:
    flashmessage:
        success:
            types:
                - { type: mytodo_success, domain: AdminBundle}

Admin class,

public function postPersist($object) {
    $this->getRequest()->getSession()->getFlashBag()->add("mytodo_success", "My To-Do custom success message");
}

It would be great if someone can help me on this. I need to change default success message witch gives 'flash_create_success' to my own message.

Upvotes: 1

Views: 1278

Answers (1)

Drmjo
Drmjo

Reputation: 584

You can create your own "translation" file .. and put it in your local resources... here's the original

https://github.com/sonata-project/SonataAdminBundle/blob/master/Resources/translations/SonataAdminBundle.en.xliff

the success message lives there ... just change the English "translation" to whatever you need... if you are using <= symfony 2.8 you can put the file in

app/Resources/SonataAdminBundle/translations/SonataAdminBundle.en.xliff

after clearing your cache.. you should be able to see new message without doing anything more...

Upvotes: 2

Related Questions