我在索纳塔很新。我有一个涉及客户和贷款的项目。在ClientsAdmin.php我已配置configureRoutes和getPersistentParameters功能索纳塔管理套件configureRoutes getPersistentParameters
protected function configureRoutes(RouteCollection $collection)
{
$collection->add('transacciones','transacciones/{id}');
}
public function getPersistentParameters()
{
if (!$this->getRequest()) {
return array();
}
return array(
'id' => $this->getRequest()->get('id'),
);
}
而且,我必须重写CRUDController(和service.yml)
//service.yml
financiera.admin.clientes:
class: BitsMkt\FinancieraBundle\Admin\ClientesAdmin
arguments: [ ~,BitsMkt\FinancieraBundle\Entity\Clientes,FinancieraBundle:ClientesCRUD]
tags:
- {name: sonata.admin, manager_type: orm, group: Sistema, label: Clientes}
//ClientesCRUDController.php
namespace Bitsmkt\FinancieraBundle\Controller;
use Sonata\AdminBundle\Controller\CRUDController;
class ClientesCRUDController extends CRUDController
{
public function transaccionesAction($id = null)
{
//throw new \RuntimeException('The Request object has not been set ' . $id);
if (false === $this->admin->isGranted('LIST')) {
throw new AccessDeniedException();
}
$id = $this->get('request')->get($this->admin->getIdParameter());
if ($id == '*') {
# TODOS - Viene de Dashboard
}else
{
$object = $this->admin->getObject($id);
if (!$object) {
throw new NotFoundHttpException(sprintf('unable to find the object with id : %s', $id));
}
$this->admin->setSubject($object);
}
$datagrid = $this->admin->getDatagrid();
$formView = $datagrid->getForm()->createView();
// set the theme for the current Admin Form
$this->get('twig')->getExtension('form')->renderer->setTheme($formView, $this->admin->getFilterTheme());
return $this->render('FinancieraBundle:Frontend:prestamos_clientes.html.twig', array(
'action' => 'list',
'form' => $formView,
'datagrid' => $datagrid,
'csrf_token' => $this->getCsrfToken('sonata.batch'),
));
}
}
的prestamos_clientes.html.twig视图,示出了客户端和贷款信息。
问题: 我想用$ id参数过滤创建的列表视图(transaccionesAction)并查看特定客户端的贷款。
谢谢。
为什么不创建贷款实体和'configuredatagridfilter管理员()'添加客户端列表 –