我正在寻找一种在奏鸣曲管理包的管理控制器中设置闪存消息的方法,它们允许将 CRUDController 中的闪存消息设置为
$this->get('session')->setFlash('sonata_flash_error', 'flash_batch_merge_error');
但不在管理控制器中,
这是我的管理员
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Route\RouteCollection;
class ConfigAdmin extends Admin
{
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->with('System Settings')
->add('Name','text', array('label' => "Configuration Name"))
->add('Language', 'choice', array(
'label' => 'System Language',
'choices' => array(0 => 'English', 1 => 'Swedish'),
'preferred_choices' => array(0),
))
->add('commonmail','text', array('label' => "Common e-Mail"))
->add('dateformat','text', array('label' => "Date format"))
->add('currencyformat','text', array('label' => "Currency format"))
->end()
}
public function postUpdate($object) {
// here i need to perform some validations and set flash message if there is an errror
}
}
感谢你的帮助