I tried to install sonata admin bundle to administrate my users.
I use FOS user bundle.
I have folowed the instructions, but anything went wrong and I don't find what.
I have the error:
Cannot automatically determine base route name, please define a default baseRouteName
value for the admin class UserBundle\Admin\UserAdmin
in C:\Users\Alexandre\hubiC\www\questionnaire\app/config. (which is being imported from "C:\Users\Alexandre\hubiC\www\questionnaire\app/config\routing.yml").
In my service I have:
services:
sonata.admin.user:
class: UserBundle\Admin\UserAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "Content", label: "User" }
arguments:
- ~
- UserBundle\Entity\User
- ~
calls:
- [ setTranslationDomain, [UserBundle]]
In my config:
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
- { resource: @UserBundle/Resources/config/admin.yml }
sonata_block:
default_contexts: [cms]
blocks:
# Enable the SonataAdminBundle block
sonata.admin.block.admin_list:
contexts: [admin]
# Your other blocks
And the file UserAdmin:
<?php //
namespace UserBundle\Admin;
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Form\FormMapper;
class UserAdmin extends Admin
{
// Fields to be shown on create/edit forms
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('nom')
->add('prenom')
->add('adresse')
->add('npa')
->add('localite')
->add('entreprise')
;
}
// Fields to be shown on filter forms
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('nom')
->add('prenom')
->add('adresse')
->add('npa')
->add('localite')
->add('entreprise')
;
}
// Fields to be shown on lists
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('nom')
->add('prenom')
->add('adresse')
->add('npa')
->add('localite')
->add('entreprise')
;
}
}
This file in the folder UserBundle/Admin.
What was wrong?
Thanks