sonata-project/SonataAdminBundle — pull request #782 by thanosp (2012-05-24 16:09:02+00:00)
Title: Adding preview mode for entities

Within an admin class the following code will enable the preview mode and show the button during create/edit.

public function supportsPreviewMode()
{
return true;
}

The view used for preview can be customized through the config or per entity by overriding the preview Template:

public function getPreviewTemplate()
{
return 'AcmeDemoBundle:Form:preview.html.twig';
}

Upon clicking preview it basically submits the form to a new window with js, where a view similar to the show-view is displayed ( the fields are the same as with the show fields). The moment the preview button loses focus the form target is again cleared so that the regular submission process will work as expected.

For my project I want to override the preview layout and use my front-end layout instead but the show-layout provides for a good default.

Would like some feedback.