src/AdminBundle/Admin/VidiFounders/FoundersPhotoAdmin.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 FoundersPhotoAdmin 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('image'MediaType::class, [
  48.                 'label' => 'Зображення',
  49.                 'required' => true,
  50.                 'provider' => 'sonata.media.provider.image',
  51.                 'context'  => 'dc_site'
  52.             ])
  53.             ->add('created'DateType::class, [
  54.                 'label' => 'Дата створення',
  55.                 'widget' => 'single_text',
  56.             ])
  57.             ->add('position'NumberType::class, [
  58.                 'label' => 'Порядок виводу',
  59.                 'required' => true,
  60.             ])
  61.             ->end();
  62.     }
  63. }