版本更新后 sonata admin 3.1 没有过滤器
No filters with sonata admin 3.1 after version update
我已将 sonata admin bundle 更新到 3.1 版本。从那以后我就不用滤镜了。有人遇到同样的问题吗?
这是我的班级管理员:
<?php
// src/CD/CarsBundle/Admin/ReservationsAdmin.php
// This code is made to custom the fields in the bloc 'Reservations' in the Admin Interface.
namespace CD\CarsBundle\Admin;
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\AdminBundle\Route\RouteCollection;
/**
*
*/
class ReservationsAdmin extends Admin
{
// This code sets up the defaut sort column and order of the informations registered in this category.
protected $datagridValues = array(
'_sort_order' => 'ASC',
'_sort_by' => 'id')
;
// This code configures the filters section on the right side of the 'Réservations' page when we click on 'Liste'.
/**
* @param DatagridMapper $datagridMapper
*/
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('id')
->add('reserve', null, array('label' => 'Réservé'))
->add('vehicules', null, array('label' => 'Véhicules - Immatriculation'), 'entity', array(
'class' => 'CD\CarsBundle\Entity\Vehicules',
'property' => 'immatriculation'
))
->add('heureDebut', null, array(
'label' => 'Date et heure de début'), 'sonata_type_datetime_picker', array(
'format' => 'dd-MM-yyyy',
'dp_side_by_side' => true,
'dp_use_current' => false,
'dp_use_seconds' => false,
))
->add('heureFin', null, array(
'label' => 'Date et heure de fin'), 'sonata_type_datetime_picker', array(
'format' => 'dd-MM-yyyy',
'dp_side_by_side' => true,
'dp_use_current' => false,
'dp_use_seconds' => false,
))
->add('nomAgent', null, array('label' => 'Nom de l\'agent'))
->add('prenomAgent', null, array('label' => 'Prénom de l\'agent'))
->add('direction', null, array('label' => 'Direction'))
//commented because not needed here ->add('commentaires', null, array('label' => 'Véhicule affecté et commentaires supplémentaires'))
;
}
// This code configures the informations listed on the 'Réservations' page when we click on 'liste'
/**
* @param ListMapper $listMapper
*/
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->add('id')
->add('vehicules', null, array('label' => 'Véhicules - Immatriculation'), 'entity', array(
'class' => 'CD\CarsBundle\Entity\Vehicules',
'property' => 'immatriculation'
))
->add('heureDebut', null, array('label' => 'Date et heure de début', 'format' => 'd-m-Y H:i'))
->add('heureFin', null, array('label' => 'Date et heure de fin', 'format' => 'd-m-Y H:i'))
->add('nomAgent', null, array('label' => 'Nom de l\'agent'))
->add('prenomAgent', null, array('label' => 'Prénom de l\'agent'))
->add('direction', null, array('label' => 'Direction'))
->add('reserve', null, array(
'label' => 'Réservé',
'editable' => true
))
->add('annulation', null, array(
'label' => 'Annulé',
'editable' => true
))
->add('remisage', null, array(
'label' => 'Remisage',
'required'=> false,
'editable' => true
))
//commented because not needed here ->add('commentaires', null, array('label' => 'Véhicule affecté et commentaires supplémentaires'))
->add('_action', 'actions', array(
'actions' => array(
'show' => array(),
'edit' => array(),
'delete' => array(),
'email' => array(
'template' => 'CDCarsBundle:Reservations:list__action_email.html.twig'),
)
))
;
}
// This code configures the fieds in the form to add a booking.
/**
* @param FormMapper $formMapper
*/
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->with('Généralités')
->add('heureDebut', 'date', array(
'label' => 'Date et heure de début',
'format' => 'dd-MM-yyyy H:i',
'years' => range(\date("Y") - 0, \date("Y") + 2),
))
->add('heureFin', 'date', array(
'label' => 'Date et heure de fin',
'format' => 'dd-MM-yyyy H:i',
'years' => range(\date("Y") - 0, \date("Y") + 2),
))
->end()
->with('Agent')
->add('nomAgent', null, array('label' => 'Nom de l\'agent'))
->add('prenomAgent', null, array('label' => 'Prénom de l\'agent'))
->add('dga', null, array('label' => 'D.G.A'))
->add('direction', null, array('label' => 'Direction'))
->add('email', null, array('label' => 'Email'))
->end()
->with('Demande')
->add('besoin', null, array('label' => 'Besoin'))
->add('nombrePersonne', null, array('label' => 'Nombre de personne'))
->end()
->with('Disponibilité')
->add('reserve', null, array('label' => 'Réservé'))
->add('annulation', null, array('label' => 'Annulé'))
->end()
->with('Remisage')
->add('remisage', null, array('label' => 'Remisage'))
->add('adresseRemisage', null, array('label' => 'Adresse'))
->add('dateDebutRemisage', null, array(
'label' => 'Du',
'format' => 'dd-MM-yyyy H:i',
'years' => range(\date("Y") - 0, \date("Y") + 2),
))
->add('dateFinRemisage', null, array(
'label' => 'au',
'format' => 'dd-MM-yyyy H:i',
'years' => range(\date("Y") - 0, \date("Y") + 2),
))
->add('emailDirecteur', null, array('label' => 'Email du Directeur'))
->end()
->with('Destination')
->add('destination', null, array('label' => 'Destination'))
->end()
->with('Motif')
->add('motifRdv', null, array('label' => 'Rendez-vous'))
->add('motifFormation', null, array('label' => 'Formation'))
->add('motifReunion', null, array('label' => 'Réunion'))
->add('motifCollecte', null, array('label' => 'Collecte'))
->add('motifInstallation', null, array('label' => 'Installation'))
->add('motifProgrammation', null, array('label' => 'Programmation'))
->add('motifDepannage', null, array('label' => 'Dépannage'))
->add('motifVad', null, array('label' => 'Visite à domicile'))
->add('motifAutre', null, array('label' => 'Autre motif'))
->end()
->with('Conducteur')
->add('conducteur', null, array('label' => 'Conducteur'))
->end()
->with('Mandataire')
->add('mandataire', null, array('label' => 'Mandataire'))
->add('nomMandataire', null, array('label' => 'Nom du mandataire'))
->add('prenomMandataire', null, array('label' => 'Prénom du mandataire'))
->add('emailMandataire', null, array('label' => 'Email du mandataire'))
->end()
->with('Attestation')
->add('honneur', null, array('label' => 'Attestation cochée'))
->end()
->with('Informations supplémentaires')
->add('commentaires', null, array('label' => 'Véhicule affecté et commentaires supplémentaires'))
// Added 'choices' to be able to reach the vehiculesrepository to find the needed informations as known as the available vehicles depends on a specific date
->add('vehicules', null, array(
'label' => 'Véhicules - Immatriculation',
'choices' => $this->getVehiculesRepository()->getAvailables($this->getEntity())
),
array(
'class' => 'CD\CarsBundle\Entity\Vehicules',
'property' => 'immatriculation'
))
->end()
;
}
// This code configures what is shown on the 'Réservations' page when we click on 'afficher'.
/**
* @param ShowMapper $showMapper
*/
protected function configureShowFields(ShowMapper $showMapper)
{
$showMapper
->with('Généralités sur la réservation')
->add('id')
->add('heureDebut', 'date', array(
'label' => 'Date et heure de début',
'format' => 'd-M-y H:i'
))
->add('heureFin', 'date', array(
'label' => 'Date et heure de fin',
'format' => 'd-M-y H:i'
))
->end()
->with('Agent')
->add('nomAgent', null, array('label' => 'Nom de l\'agent'))
->add('prenomAgent', null, array('label' => 'Prénom de l\'agent'))
->add('dga', null, array('label' => 'D.G.A'))
->add('direction', null, array('label' => 'Direction'))
->add('email', null, array('label' => 'Email'))
->end()
->with('Demande')
->add('besoin', null, array('label' => 'Besoin'))
->add('nombrePersonne', null, array('label' => 'Nombre de personne'))
->end()
->with('Disponibilité')
->add('reserve', null, array('label' => 'Réservé'))
->add('annulation', null, array('label' => 'Annulé'))
->end()
->with('Remisage')
->add('remisage', null, array('label' => 'Remisage'))
->add('adresseRemisage', null, array('label' => 'Adresse'))
->add('dateDebutRemisage', null, array(
'label' => 'Du',
'format' => 'd-M-y H:i'
))
->add('dateFinRemisage', null, array(
'label' => 'au',
'format' => 'd-M-y H:i'
))
->add('emailDirecteur', null, array('label' => 'Email du Directeur'))
->end()
->with('Destination')
->add('destination', null, array('label' => 'Destination'))
->end()
->with('Motif')
->add('motifRdv', null, array('label' => 'Rendez-vous'))
->add('motifFormation', null, array('label' => 'Formation'))
->add('motifReunion', null, array('label' => 'Réunion'))
->add('motifCollecte', null, array('label' => 'Collecte'))
->add('motifInstallation', null, array('label' => 'Installation'))
->add('motifProgrammation', null, array('label' => 'Programmation'))
->add('motifDepannage', null, array('label' => 'Dépannage'))
->add('motifVad', null, array('label' => 'Visite à domicile'))
->add('motifAutre', null, array('label' => 'Autre motif'))
->end()
->with('Conducteur')
->add('conducteur', null, array('label' => 'Conducteur'))
->end()
->with('Mandataire')
->add('mandataire', null, array('label' => 'Mandataire'))
->add('nomMandataire', null, array('label' => 'Nom du mandataire'))
->add('prenomMandataire', null, array('label' => 'Prénom du mandataire'))
->add('emailMandataire', null, array('label' => 'Email du mandataire'))
->end()
->with('Attestation')
->add('honneur', null, array('label' => 'Attestation cochée'))
->end()
->with('Informations supplémentaires')
->add('commentaires', null, array('label' => 'Véhicule affecté et commentaires supplémentaires'))
->add('vehicules', null, array('label' => 'Véhicules - Immatriculation'), array(
'class' => 'CD\CarsBundle\Entity\Vehicules',
'property' => 'immatriculation'
))
->end()
;
}
// Added a custom action in the listfields = email
protected function configureRoutes(RouteCollection $collection)
{
$collection->add('email', $this->getRouterIdParameter().'cd_cars_reservations');
}
// Used to go to pin on the vehiculerepository
/**
* @return \CD\CarsBundle\Entity\VehiculesRepository
*/
private function getVehiculesRepository()
{
return $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository('CDCarsBundle:Vehicules');
}
// Used to reach the enity
private function getEntity()
{
return $this->getRoot()->getSubject();
}
}
实体:
# ORM for the "Reservations" entity with fields and mapping between database tables
CD\CarsBundle\Entity\Reservations:
type: entity
table: null
repositoryClass: CD\CarsBundle\Entity\ReservationsRepository
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
heureDebut:
type: datetime
heureFin:
type: datetime
nomAgent:
type: string
length: 255
prenomAgent:
type: string
length: 255
dga:
type: string
length: 255
nullable: true
direction:
type: string
length: 255
email:
type: string
length: 255
nullable: true
telephone:
type: string
length: 255
nullable: true
destination:
type: text
reserve:
type: boolean
nullable: true
annulation:
type: boolean
nullable: true
remisage:
type: boolean
nullable: true
adresseRemisage:
type: text
nullable: true
dateDebutRemisage:
type: date
nullable: true
dateFinRemisage:
type: date
nullable: true
emailDirecteur:
type: string
length: 255
nullable: true
conducteur:
type: boolean
nullable: true
mandataire:
type: boolean
nullable: true
motifRdv:
type: boolean
column: motif_rdv
nullable: true
motifFormation:
type: boolean
column: motif_formation
nullable: true
motifReunion:
type: boolean
column: motif_reunion
nullable: true
motifCollecte:
type: boolean
column: motif_collecte
nullable: true
motifInstallation:
type: boolean
column: motif_installation
nullable: true
motifProgrammation:
type: boolean
column: motif_programmation
nullable: true
motifDepannage:
type: boolean
column: motif_depannage
nullable: true
motifVad:
type: boolean
column: motif_vad
nullable: true
motifAutre:
type: text
column: motif_autre
nullable: true
commentaires:
type: text
nullable: true
nombrePersonne:
type: integer
column: nombre_personne
nullable: true
besoin:
type: string
column: besoin
nullable: true
nomMandataire:
type: string
length: 255
column: nom_mandataire
nullable: true
prenomMandataire:
type: string
length: 255
column: prenom_mandataire
nullable: true
emailMandataire:
type: string
length: 255
column: email_mandataire
nullable: true
honneur:
type: boolean
column: honneur
nullable: true
manyToOne:
vehicules:
targetEntity: Vehicules
inversedBy: reservations
joinColumn:
name: vehicules_id
referenceColumnName: id
cascade: [persist]
user:
targetEntity: Application\Sonata\UserBundle\Entity\User
inversedBy: reservations
joinColumn:
name: user_id
referenceColumnName: id
pool:
targetEntity: Pool
inversedBy: reservations
joinColumn:
name: pool_id
referenceColumnName: id
cascade: [persist]
lifecycleCallbacks: { }
还有我的composer.json
{
"name" : "cosylvestre/flotte",
"license" : "proprietary",
"type" : "project",
"autoload" : {
"psr-4" : {
"" : "src/"
}
},
"require" : {
"php" : ">=5.3.9",
"symfony/symfony" : "2.7.*",
"doctrine/orm" : "^2.4.8",
"doctrine/doctrine-bundle" : "~1.4",
"symfony/assetic-bundle" : "~2.3",
"symfony/swiftmailer-bundle" : "~2.3",
"symfony/monolog-bundle" : "~2.4",
"sensio/distribution-bundle" : "~4.0",
"sensio/framework-extra-bundle" : "^3.0.2",
"incenteev/composer-parameter-handler" : "~2.0",
"sonata-project/admin-bundle" : "^3.1",
"sonata-project/doctrine-orm-admin-bundle" : "3.0.4",
"sonata-project/easy-extends-bundle" : "^2.1",
"sonata-project/user-bundle" : "3.0.1",
"sonata-project/core-bundle" : "^3.0"
},
"require-dev" : {
"sensio/generator-bundle" : "~2.3",
"symfony/phpunit-bridge" : "~2.7",
"phpunit/phpunit" : "4.8.24",
"doctrine/doctrine-fixtures-bundle" : "^2.3",
"liip/functional-test-bundle" : "1.0.*"
},
"scripts" : {
"post-install-cmd" : [
"Incenteev\ParameterHandler\ScriptHandler::buildParameters",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget"
],
"post-update-cmd" : [
"Incenteev\ParameterHandler\ScriptHandler::buildParameters",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget"
]
},
"config" : {
"bin-dir" : "bin",
"platform" : {
"php" : "5.3.9"
}
},
"extra" : {
"symfony-app-dir" : "app",
"symfony-web-dir" : "web",
"symfony-assets-install" : "relative",
"incenteev-parameters" : {
"file" : "app/config/parameters.yml"
}
}
}
而且我在编辑页面时没有时间和分钟。我只有 d-m-y。但我也需要h:m。
感谢您的帮助。
All filters are hidden by default for space-saving. User has to check
which filter he wants to use.
To make the filter always visible (even when it is inactive), set the
parameter show_filter to true.
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('phone')
->add('email', null, array(
'show_filter' => true
))
// ...
;
}
我会尝试设置 'show_filter'
选项....
对于小时和分钟,您必须使用 datetime
而不是 date
字段类型
我已将 sonata admin bundle 更新到 3.1 版本。从那以后我就不用滤镜了。有人遇到同样的问题吗?
这是我的班级管理员:
<?php
// src/CD/CarsBundle/Admin/ReservationsAdmin.php
// This code is made to custom the fields in the bloc 'Reservations' in the Admin Interface.
namespace CD\CarsBundle\Admin;
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\AdminBundle\Route\RouteCollection;
/**
*
*/
class ReservationsAdmin extends Admin
{
// This code sets up the defaut sort column and order of the informations registered in this category.
protected $datagridValues = array(
'_sort_order' => 'ASC',
'_sort_by' => 'id')
;
// This code configures the filters section on the right side of the 'Réservations' page when we click on 'Liste'.
/**
* @param DatagridMapper $datagridMapper
*/
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('id')
->add('reserve', null, array('label' => 'Réservé'))
->add('vehicules', null, array('label' => 'Véhicules - Immatriculation'), 'entity', array(
'class' => 'CD\CarsBundle\Entity\Vehicules',
'property' => 'immatriculation'
))
->add('heureDebut', null, array(
'label' => 'Date et heure de début'), 'sonata_type_datetime_picker', array(
'format' => 'dd-MM-yyyy',
'dp_side_by_side' => true,
'dp_use_current' => false,
'dp_use_seconds' => false,
))
->add('heureFin', null, array(
'label' => 'Date et heure de fin'), 'sonata_type_datetime_picker', array(
'format' => 'dd-MM-yyyy',
'dp_side_by_side' => true,
'dp_use_current' => false,
'dp_use_seconds' => false,
))
->add('nomAgent', null, array('label' => 'Nom de l\'agent'))
->add('prenomAgent', null, array('label' => 'Prénom de l\'agent'))
->add('direction', null, array('label' => 'Direction'))
//commented because not needed here ->add('commentaires', null, array('label' => 'Véhicule affecté et commentaires supplémentaires'))
;
}
// This code configures the informations listed on the 'Réservations' page when we click on 'liste'
/**
* @param ListMapper $listMapper
*/
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->add('id')
->add('vehicules', null, array('label' => 'Véhicules - Immatriculation'), 'entity', array(
'class' => 'CD\CarsBundle\Entity\Vehicules',
'property' => 'immatriculation'
))
->add('heureDebut', null, array('label' => 'Date et heure de début', 'format' => 'd-m-Y H:i'))
->add('heureFin', null, array('label' => 'Date et heure de fin', 'format' => 'd-m-Y H:i'))
->add('nomAgent', null, array('label' => 'Nom de l\'agent'))
->add('prenomAgent', null, array('label' => 'Prénom de l\'agent'))
->add('direction', null, array('label' => 'Direction'))
->add('reserve', null, array(
'label' => 'Réservé',
'editable' => true
))
->add('annulation', null, array(
'label' => 'Annulé',
'editable' => true
))
->add('remisage', null, array(
'label' => 'Remisage',
'required'=> false,
'editable' => true
))
//commented because not needed here ->add('commentaires', null, array('label' => 'Véhicule affecté et commentaires supplémentaires'))
->add('_action', 'actions', array(
'actions' => array(
'show' => array(),
'edit' => array(),
'delete' => array(),
'email' => array(
'template' => 'CDCarsBundle:Reservations:list__action_email.html.twig'),
)
))
;
}
// This code configures the fieds in the form to add a booking.
/**
* @param FormMapper $formMapper
*/
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->with('Généralités')
->add('heureDebut', 'date', array(
'label' => 'Date et heure de début',
'format' => 'dd-MM-yyyy H:i',
'years' => range(\date("Y") - 0, \date("Y") + 2),
))
->add('heureFin', 'date', array(
'label' => 'Date et heure de fin',
'format' => 'dd-MM-yyyy H:i',
'years' => range(\date("Y") - 0, \date("Y") + 2),
))
->end()
->with('Agent')
->add('nomAgent', null, array('label' => 'Nom de l\'agent'))
->add('prenomAgent', null, array('label' => 'Prénom de l\'agent'))
->add('dga', null, array('label' => 'D.G.A'))
->add('direction', null, array('label' => 'Direction'))
->add('email', null, array('label' => 'Email'))
->end()
->with('Demande')
->add('besoin', null, array('label' => 'Besoin'))
->add('nombrePersonne', null, array('label' => 'Nombre de personne'))
->end()
->with('Disponibilité')
->add('reserve', null, array('label' => 'Réservé'))
->add('annulation', null, array('label' => 'Annulé'))
->end()
->with('Remisage')
->add('remisage', null, array('label' => 'Remisage'))
->add('adresseRemisage', null, array('label' => 'Adresse'))
->add('dateDebutRemisage', null, array(
'label' => 'Du',
'format' => 'dd-MM-yyyy H:i',
'years' => range(\date("Y") - 0, \date("Y") + 2),
))
->add('dateFinRemisage', null, array(
'label' => 'au',
'format' => 'dd-MM-yyyy H:i',
'years' => range(\date("Y") - 0, \date("Y") + 2),
))
->add('emailDirecteur', null, array('label' => 'Email du Directeur'))
->end()
->with('Destination')
->add('destination', null, array('label' => 'Destination'))
->end()
->with('Motif')
->add('motifRdv', null, array('label' => 'Rendez-vous'))
->add('motifFormation', null, array('label' => 'Formation'))
->add('motifReunion', null, array('label' => 'Réunion'))
->add('motifCollecte', null, array('label' => 'Collecte'))
->add('motifInstallation', null, array('label' => 'Installation'))
->add('motifProgrammation', null, array('label' => 'Programmation'))
->add('motifDepannage', null, array('label' => 'Dépannage'))
->add('motifVad', null, array('label' => 'Visite à domicile'))
->add('motifAutre', null, array('label' => 'Autre motif'))
->end()
->with('Conducteur')
->add('conducteur', null, array('label' => 'Conducteur'))
->end()
->with('Mandataire')
->add('mandataire', null, array('label' => 'Mandataire'))
->add('nomMandataire', null, array('label' => 'Nom du mandataire'))
->add('prenomMandataire', null, array('label' => 'Prénom du mandataire'))
->add('emailMandataire', null, array('label' => 'Email du mandataire'))
->end()
->with('Attestation')
->add('honneur', null, array('label' => 'Attestation cochée'))
->end()
->with('Informations supplémentaires')
->add('commentaires', null, array('label' => 'Véhicule affecté et commentaires supplémentaires'))
// Added 'choices' to be able to reach the vehiculesrepository to find the needed informations as known as the available vehicles depends on a specific date
->add('vehicules', null, array(
'label' => 'Véhicules - Immatriculation',
'choices' => $this->getVehiculesRepository()->getAvailables($this->getEntity())
),
array(
'class' => 'CD\CarsBundle\Entity\Vehicules',
'property' => 'immatriculation'
))
->end()
;
}
// This code configures what is shown on the 'Réservations' page when we click on 'afficher'.
/**
* @param ShowMapper $showMapper
*/
protected function configureShowFields(ShowMapper $showMapper)
{
$showMapper
->with('Généralités sur la réservation')
->add('id')
->add('heureDebut', 'date', array(
'label' => 'Date et heure de début',
'format' => 'd-M-y H:i'
))
->add('heureFin', 'date', array(
'label' => 'Date et heure de fin',
'format' => 'd-M-y H:i'
))
->end()
->with('Agent')
->add('nomAgent', null, array('label' => 'Nom de l\'agent'))
->add('prenomAgent', null, array('label' => 'Prénom de l\'agent'))
->add('dga', null, array('label' => 'D.G.A'))
->add('direction', null, array('label' => 'Direction'))
->add('email', null, array('label' => 'Email'))
->end()
->with('Demande')
->add('besoin', null, array('label' => 'Besoin'))
->add('nombrePersonne', null, array('label' => 'Nombre de personne'))
->end()
->with('Disponibilité')
->add('reserve', null, array('label' => 'Réservé'))
->add('annulation', null, array('label' => 'Annulé'))
->end()
->with('Remisage')
->add('remisage', null, array('label' => 'Remisage'))
->add('adresseRemisage', null, array('label' => 'Adresse'))
->add('dateDebutRemisage', null, array(
'label' => 'Du',
'format' => 'd-M-y H:i'
))
->add('dateFinRemisage', null, array(
'label' => 'au',
'format' => 'd-M-y H:i'
))
->add('emailDirecteur', null, array('label' => 'Email du Directeur'))
->end()
->with('Destination')
->add('destination', null, array('label' => 'Destination'))
->end()
->with('Motif')
->add('motifRdv', null, array('label' => 'Rendez-vous'))
->add('motifFormation', null, array('label' => 'Formation'))
->add('motifReunion', null, array('label' => 'Réunion'))
->add('motifCollecte', null, array('label' => 'Collecte'))
->add('motifInstallation', null, array('label' => 'Installation'))
->add('motifProgrammation', null, array('label' => 'Programmation'))
->add('motifDepannage', null, array('label' => 'Dépannage'))
->add('motifVad', null, array('label' => 'Visite à domicile'))
->add('motifAutre', null, array('label' => 'Autre motif'))
->end()
->with('Conducteur')
->add('conducteur', null, array('label' => 'Conducteur'))
->end()
->with('Mandataire')
->add('mandataire', null, array('label' => 'Mandataire'))
->add('nomMandataire', null, array('label' => 'Nom du mandataire'))
->add('prenomMandataire', null, array('label' => 'Prénom du mandataire'))
->add('emailMandataire', null, array('label' => 'Email du mandataire'))
->end()
->with('Attestation')
->add('honneur', null, array('label' => 'Attestation cochée'))
->end()
->with('Informations supplémentaires')
->add('commentaires', null, array('label' => 'Véhicule affecté et commentaires supplémentaires'))
->add('vehicules', null, array('label' => 'Véhicules - Immatriculation'), array(
'class' => 'CD\CarsBundle\Entity\Vehicules',
'property' => 'immatriculation'
))
->end()
;
}
// Added a custom action in the listfields = email
protected function configureRoutes(RouteCollection $collection)
{
$collection->add('email', $this->getRouterIdParameter().'cd_cars_reservations');
}
// Used to go to pin on the vehiculerepository
/**
* @return \CD\CarsBundle\Entity\VehiculesRepository
*/
private function getVehiculesRepository()
{
return $this->getConfigurationPool()->getContainer()->get('doctrine')->getRepository('CDCarsBundle:Vehicules');
}
// Used to reach the enity
private function getEntity()
{
return $this->getRoot()->getSubject();
}
}
实体:
# ORM for the "Reservations" entity with fields and mapping between database tables
CD\CarsBundle\Entity\Reservations:
type: entity
table: null
repositoryClass: CD\CarsBundle\Entity\ReservationsRepository
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
heureDebut:
type: datetime
heureFin:
type: datetime
nomAgent:
type: string
length: 255
prenomAgent:
type: string
length: 255
dga:
type: string
length: 255
nullable: true
direction:
type: string
length: 255
email:
type: string
length: 255
nullable: true
telephone:
type: string
length: 255
nullable: true
destination:
type: text
reserve:
type: boolean
nullable: true
annulation:
type: boolean
nullable: true
remisage:
type: boolean
nullable: true
adresseRemisage:
type: text
nullable: true
dateDebutRemisage:
type: date
nullable: true
dateFinRemisage:
type: date
nullable: true
emailDirecteur:
type: string
length: 255
nullable: true
conducteur:
type: boolean
nullable: true
mandataire:
type: boolean
nullable: true
motifRdv:
type: boolean
column: motif_rdv
nullable: true
motifFormation:
type: boolean
column: motif_formation
nullable: true
motifReunion:
type: boolean
column: motif_reunion
nullable: true
motifCollecte:
type: boolean
column: motif_collecte
nullable: true
motifInstallation:
type: boolean
column: motif_installation
nullable: true
motifProgrammation:
type: boolean
column: motif_programmation
nullable: true
motifDepannage:
type: boolean
column: motif_depannage
nullable: true
motifVad:
type: boolean
column: motif_vad
nullable: true
motifAutre:
type: text
column: motif_autre
nullable: true
commentaires:
type: text
nullable: true
nombrePersonne:
type: integer
column: nombre_personne
nullable: true
besoin:
type: string
column: besoin
nullable: true
nomMandataire:
type: string
length: 255
column: nom_mandataire
nullable: true
prenomMandataire:
type: string
length: 255
column: prenom_mandataire
nullable: true
emailMandataire:
type: string
length: 255
column: email_mandataire
nullable: true
honneur:
type: boolean
column: honneur
nullable: true
manyToOne:
vehicules:
targetEntity: Vehicules
inversedBy: reservations
joinColumn:
name: vehicules_id
referenceColumnName: id
cascade: [persist]
user:
targetEntity: Application\Sonata\UserBundle\Entity\User
inversedBy: reservations
joinColumn:
name: user_id
referenceColumnName: id
pool:
targetEntity: Pool
inversedBy: reservations
joinColumn:
name: pool_id
referenceColumnName: id
cascade: [persist]
lifecycleCallbacks: { }
还有我的composer.json
{
"name" : "cosylvestre/flotte",
"license" : "proprietary",
"type" : "project",
"autoload" : {
"psr-4" : {
"" : "src/"
}
},
"require" : {
"php" : ">=5.3.9",
"symfony/symfony" : "2.7.*",
"doctrine/orm" : "^2.4.8",
"doctrine/doctrine-bundle" : "~1.4",
"symfony/assetic-bundle" : "~2.3",
"symfony/swiftmailer-bundle" : "~2.3",
"symfony/monolog-bundle" : "~2.4",
"sensio/distribution-bundle" : "~4.0",
"sensio/framework-extra-bundle" : "^3.0.2",
"incenteev/composer-parameter-handler" : "~2.0",
"sonata-project/admin-bundle" : "^3.1",
"sonata-project/doctrine-orm-admin-bundle" : "3.0.4",
"sonata-project/easy-extends-bundle" : "^2.1",
"sonata-project/user-bundle" : "3.0.1",
"sonata-project/core-bundle" : "^3.0"
},
"require-dev" : {
"sensio/generator-bundle" : "~2.3",
"symfony/phpunit-bridge" : "~2.7",
"phpunit/phpunit" : "4.8.24",
"doctrine/doctrine-fixtures-bundle" : "^2.3",
"liip/functional-test-bundle" : "1.0.*"
},
"scripts" : {
"post-install-cmd" : [
"Incenteev\ParameterHandler\ScriptHandler::buildParameters",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget"
],
"post-update-cmd" : [
"Incenteev\ParameterHandler\ScriptHandler::buildParameters",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget"
]
},
"config" : {
"bin-dir" : "bin",
"platform" : {
"php" : "5.3.9"
}
},
"extra" : {
"symfony-app-dir" : "app",
"symfony-web-dir" : "web",
"symfony-assets-install" : "relative",
"incenteev-parameters" : {
"file" : "app/config/parameters.yml"
}
}
}
而且我在编辑页面时没有时间和分钟。我只有 d-m-y。但我也需要h:m。
感谢您的帮助。
All filters are hidden by default for space-saving. User has to check which filter he wants to use.
To make the filter always visible (even when it is inactive), set the parameter show_filter to true.
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('phone')
->add('email', null, array(
'show_filter' => true
))
// ...
;
}
我会尝试设置 'show_filter'
选项....
对于小时和分钟,您必须使用 datetime
而不是 date
字段类型