src/AdminBundle/Admin/Vehicles/VehicleContentAdmin.php line 16

Open in your IDE?
  1. <?php
  2. namespace AdminBundle\Admin\Vehicles;
  3. use AdminBundle\Admin\BaseAdmin;
  4. use AdminBundle\Form\Type\Vehicle\InterestingType;
  5. use AdminBundle\Form\Type\Vehicle\TableMainCharacteristicsType;
  6. use CoreBundle\Entity\Vehicles\VehicleContent;
  7. use FOS\CKEditorBundle\Form\Type\CKEditorType;
  8. use Sonata\AdminBundle\Form\FormMapper;
  9. use Sonata\MediaBundle\Form\Type\MediaType;
  10. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  11. class VehicleContentAdmin extends BaseAdmin
  12. {
  13.     protected function configureFormFields(FormMapper $formMapper): void
  14.     {
  15.         /** @var VehicleContent $Content */
  16.         $Content $this->getSubject();
  17.         $vehicle $Content->getVehicle();
  18.         $isUsed $vehicle && $vehicle->getIsUsed();
  19.         if($isUsed) {
  20.             $formMapper
  21.                 ->with('Основная информация', ['class' => 'col-lg-6'])
  22.                     ->add('content'CKEditorType::class, [
  23.                         'config_name' => 'default',
  24.                         'required' => false,
  25.                         'label' => 'Контент'
  26.                     ])
  27.                     ->add('seo_title'null, ['label' => 'SEO Title''required' => false])
  28.                     ->add('seo_description'TextareaType::class, ['label' => 'SEO Description''required' => false])
  29.                     ->add('seo_keywords'TextareaType::class, ['label' => 'SEO Keywords''required' => false])
  30.                 ->end()
  31.             ;
  32.         } else {
  33.             $formMapper
  34.                 ->with('Основная информация', ['class' => 'col-lg-6'])
  35.                     ->add('title'null, ['label' => 'Название модели'])
  36.                     ->add('slogan'null, ['label' => 'Приставка к заголовку H1'])
  37.                     ->add('description'CKEditorType::class, ['label' => 'Краткое описание','config_name' => 'default','required' => false])
  38.                     ->add('content'CKEditorType::class, [
  39.                         'config_name' => 'default',
  40.                         'required' => false,
  41.                         'label' => 'Контент'
  42.                     ])
  43.                     ->add('seo_title'null, ['label' => 'SEO Title''required' => false])
  44.                     ->add('seo_description'TextareaType::class, ['label' => 'SEO Description''required' => false])
  45.                     ->add('seo_keywords'TextareaType::class, ['label' => 'SEO Keywords''required' => false])
  46.                 ->end()
  47.                 ->with('Основная информация', ['class' => 'col-lg-6'])
  48.                 ->add('main_characteristics'TableMainCharacteristicsType::class, [
  49.                     'label' => 'Основные характеристики',
  50.                     'help' => 'Введите данные в таблицу',
  51.                     'attr' => [
  52.                         'style' => 'display: grid;
  53.                                     grid-template-columns: 1fr 1fr 1fr 1fr;
  54.                                     gap: 20px;',
  55.                     ]
  56.                 ])
  57.                 ->end()
  58.                 ->with('Основная информация', ['class' => 'col-lg-6'])
  59.                 ->add('interesting_image'MediaType::class, [
  60.                     'label' => 'Основное изображение "Вас це може зацікавити"',
  61.                     'required' => false,
  62.                     'provider' => 'sonata.media.provider.image',
  63.                     'context'  => 'dc_site'
  64.                 ])
  65.                 ->add('interesting'InterestingType::class, [
  66.                     'label' => 'Вас це може зацікавити',
  67.                     'help' => '<hr style="margin: 20px 0; border: 1px solid #ddd;">'
  68.                 ])
  69.                 ->end();
  70.             ;
  71.         }
  72.     }
  73. }