src/AdminBundle/Admin/DirectionOfProductionAdmin.php line 10

Open in your IDE?
  1. <?php
  2. namespace AdminBundle\Admin;
  3. use Sonata\AdminBundle\Datagrid\ListMapper;
  4. use Sonata\AdminBundle\Form\FormMapper;
  5. use Sonata\MediaBundle\Form\Type\MediaType;
  6. use Sonata\AdminBundle\Route\RouteCollectionInterface;
  7. class DirectionOfProductionAdmin extends BaseAdmin
  8. {
  9.     /**
  10.      * @param RouteCollectionInterface $collection
  11.      */
  12.     protected function configureRoutes(RouteCollectionInterface $collection): void
  13.     {
  14.         $collection->remove('view');
  15.         $collection->remove('delete');
  16.     }
  17.     /**
  18.      * @param FormMapper $formMapper
  19.      */
  20.     protected function configureFormFields(FormMapper $formMapper): void
  21.     {
  22.         $formMapper
  23.             ->with('Контент', ['class' => 'col-md-6'])
  24.                 ->add('title_ru',null, ['label' => 'Название категории (RU)'])
  25.                 ->add('title_ua',null, ['label' => 'Название категории (UA)'])
  26.                 ->add('url'null, ['label' => 'Ссылка''required' => true])
  27.                 ->add('image'MediaType::class, [
  28.                     'label' => 'Изображение',
  29.                     'required' => false,
  30.                     'provider' => 'sonata.media.provider.image',
  31.                     'context'  => 'dc_site'
  32.                 ])
  33.                 ->end()
  34.             ->with('Описание', ['class' => 'col-md-6'])
  35.                 ->add('description_ru',null, ['label' => 'Описание (RU)'])
  36.                 ->add('description_ua',null, ['label' => 'Описание (UA)'])
  37.                 ->end()
  38.         ;
  39.     }
  40.     /**
  41.      * @param ListMapper $listMapper
  42.      */
  43.     protected function configureListFields(ListMapper $listMapper): void
  44.     {
  45.         $listMapper->addIdentifier('id')
  46.             ->add('title_ru',null, ['label' => 'Название (RU)'])
  47.             ->add('title_ua',null, ['label' => 'Название (UA)'])
  48.             ->add('_action''actions', array(
  49.                 'label' => 'Действия',
  50.                 'actions' => array(
  51.                     'edit' => array(),
  52.                 )
  53.             ))
  54.         ;
  55.     }
  56. }