src/AdminBundle/Admin/VidiFounders/FoundersVideoAdmin.php line 15

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\Form\Extension\Core\Type\TextareaType;
  11. use Symfony\Component\Validator\Constraints\Length;
  12. class FoundersVideoAdmin extends BaseAdmin
  13. {
  14.     protected function configureListFields(ListMapper $list): void
  15.     {
  16.         $list->addIdentifier('id')
  17.             ->add('title_ua'null, ['label' => 'Заголовок'])
  18.             ->add('created'null, ['label' => 'Створенний'])
  19.             ->add('position'null, ['label' => 'Позиция'])
  20.             ->add('_action''actions', [
  21.                 'label' => 'Действия',
  22.                 'actions' => [
  23.                     'edit' => []
  24.                 ]
  25.             ]);
  26.     }
  27.     protected function configureFormFields(FormMapper $form): void
  28.     {
  29.         $form->add('title_ua'null, ['label' => 'Заголовок UA''required' => true,
  30.             'attr' => ['maxlength' => 125],
  31.             'constraints' => [
  32.                 new Length([
  33.                     'max' => 125,
  34.                     'maxMessage' => 'Заголовок не може містити більше {{ limit }} символів.'
  35.                 ])
  36.             ]
  37.             ])
  38.             ->add('title_ru'null, ['label' => 'Заголовок RU''required' => true,
  39.                 'attr' => ['maxlength' => 125],
  40.                 'constraints' => [
  41.                     new Length([
  42.                         'max' => 125,
  43.                         'maxMessage' => 'Заголовок не може містити більше {{ limit }} символів.'
  44.                     ])
  45.                 ]
  46.                 ])
  47.             ->add('video'null, ['label' => 'Посилання на відео''required' => true])
  48.             ->add('image_preview'MediaType::class, [
  49.                 'label' => 'Попередній перегляд',
  50.                 'required' => true,
  51.                 'provider' => 'sonata.media.provider.image',
  52.                 'context'  => 'dc_site'
  53.             ])
  54.             ->add('created'DateType::class, [
  55.                 'label' => 'Дата створення',
  56.                 'widget' => 'single_text',
  57.             ])
  58.             ->add('position'NumberType::class, [
  59.                 'label' => 'Порядок виводу',
  60.                 'required' => true,
  61.             ])
  62.             ->end();
  63.     }
  64. }