简体   繁体   中英

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.

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...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM