src/AdminBundle/Admin/VidiFounders/FoundersPublicationsAdmin.php line 14

Open in your IDE?
  1. <?php
  2. namespace AdminBundle\Admin\VidiFounders;
  3. use AdminBundle\Admin\BaseAdmin;
  4. use FOS\CKEditorBundle\Form\Type\CKEditorType;
  5. use Sonata\AdminBundle\Datagrid\ListMapper;
  6. use Sonata\AdminBundle\Form\FormMapper;
  7. use Sonata\MediaBundle\Form\Type\MediaType;
  8. use Symfony\Component\Form\Extension\Core\Type\DateType;
  9. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  10. use Symfony\Component\Validator\Constraints\Length;
  11. class FoundersPublicationsAdmin extends BaseAdmin
  12. {
  13.     protected function configureListFields(ListMapper $list): void
  14.     {
  15.         $list->addIdentifier('id')
  16.             ->add('title_ua'null, ['label' => 'Заголовок'])
  17.             ->add('created'null, ['label' => 'Створенний'])
  18.             ->add('position'null, ['label' => 'Позиция'])
  19.             ->add('_action''actions', [
  20.                 'label' => 'Действия',
  21.                 'actions' => [
  22.                     'edit' => []
  23.                 ]
  24.             ]);
  25.     }
  26.     protected function configureFormFields(FormMapper $form): void
  27.     {
  28.         $form->add('title_ua'null, [
  29.             'label' => 'Заголовок UA',
  30.             'required' => true,
  31.             'attr' => ['maxlength' => 125],
  32.             'constraints' => [
  33.                 new Length([
  34.                     'max' => 125,
  35.                     'maxMessage' => 'Заголовок не може містити більше {{ limit }} символів.'
  36.                 ])
  37.             ]
  38.         ])
  39.             ->add('title_ru'null, [
  40.                 'label' => 'Заголовок RU',
  41.                 'required' => true,
  42.                 'attr' => ['maxlength' => 125],
  43.                 'constraints' => [
  44.                     new Length([
  45.                         'max' => 125,
  46.                         'maxMessage' => 'Заголовок не може містити більше {{ limit }} символів.'
  47.                     ])
  48.                 ]
  49.             ])
  50.             ->add('text_ua'CKEditorType::class, ['label' => 'Текст UA''required' => true])
  51.             ->add('text_ru'CKEditorType::class, ['label' => 'Текст RU''required' => true])
  52.             ->add('publication_source_ua'null, [
  53.                 'label' => 'Джерело публікації UA',
  54.                 'required' => true,
  55.                 'attr' => ['maxlength' => 50],
  56.                 'constraints' => [
  57.                     new Length([
  58.                         'max' => 50,
  59.                         'maxMessage' => 'Джерело публікації не може містити більше {{ limit }} символів.'
  60.                     ])
  61.                 ]
  62.             ])
  63.             ->add('publication_source_ru'null, [
  64.                 'label' => 'Джерело публікації RU',
  65.                 'required' => true,
  66.                 'attr' => ['maxlength' => 50],
  67.                 'constraints' => [
  68.                     new Length([
  69.                         'max' => 50,
  70.                         'maxMessage' => 'Джерело публікації не може містити більше {{ limit }} символів.'
  71.                     ])
  72.                 ]
  73.             ])
  74.             ->add('image_preview'MediaType::class, [
  75.                 'label' => 'Попередній перегляд',
  76.                 'required' => true,
  77.                 'provider' => 'sonata.media.provider.image',
  78.                 'context'  => 'dc_site'
  79.             ])
  80.             ->add('image'MediaType::class, [
  81.                 'label' => 'Зображення',
  82.                 'required' => true,
  83.                 'provider' => 'sonata.media.provider.image',
  84.                 'context'  => 'dc_site'
  85.             ])
  86.             ->add('created'DateType::class, [
  87.                 'label' => 'Дата створення',
  88.                 'widget' => 'single_text',
  89.             ])
  90.             ->add('position'NumberType::class, [
  91.                 'label' => 'Порядок виводу',
  92.                 'required' => true,
  93.             ])
  94.             ->end();
  95.     }
  96. }