- <?php
- namespace AdminBundle\Admin\Vehicles;
- use AdminBundle\Admin\BaseAdmin;
- use AdminBundle\Form\Type\Vehicle\InterestingType;
- use AdminBundle\Form\Type\Vehicle\TableMainCharacteristicsType;
- use CoreBundle\Entity\Vehicles\VehicleContent;
- use FOS\CKEditorBundle\Form\Type\CKEditorType;
- use Sonata\AdminBundle\Form\FormMapper;
- use Sonata\MediaBundle\Form\Type\MediaType;
- use Symfony\Component\Form\Extension\Core\Type\TextareaType;
- class VehicleContentAdmin extends BaseAdmin
- {
-     protected function configureFormFields(FormMapper $formMapper): void
-     {
-         /** @var VehicleContent $Content */
-         $Content = $this->getSubject();
-         $vehicle = $Content->getVehicle();
-         $isUsed = $vehicle && $vehicle->getIsUsed();
-         if($isUsed) {
-             $formMapper
-                 ->with('Основная информация', ['class' => 'col-lg-6'])
-                     ->add('content', CKEditorType::class, [
-                         'config_name' => 'default',
-                         'required' => false,
-                         'label' => 'Контент'
-                     ])
-                     ->add('seo_title', null, ['label' => 'SEO Title', 'required' => false])
-                     ->add('seo_description', TextareaType::class, ['label' => 'SEO Description', 'required' => false])
-                     ->add('seo_keywords', TextareaType::class, ['label' => 'SEO Keywords', 'required' => false])
-                 ->end()
-             ;
-         } else {
-             $formMapper
-                 ->with('Основная информация', ['class' => 'col-lg-6'])
-                     ->add('title', null, ['label' => 'Название модели'])
-                     ->add('slogan', null, ['label' => 'Приставка к заголовку H1'])
-                     ->add('description', CKEditorType::class, ['label' => 'Краткое описание','config_name' => 'default','required' => false])
-                     ->add('content', CKEditorType::class, [
-                         'config_name' => 'default',
-                         'required' => false,
-                         'label' => 'Контент'
-                     ])
-                     ->add('seo_title', null, ['label' => 'SEO Title', 'required' => false])
-                     ->add('seo_description', TextareaType::class, ['label' => 'SEO Description', 'required' => false])
-                     ->add('seo_keywords', TextareaType::class, ['label' => 'SEO Keywords', 'required' => false])
-                 ->end()
-                 ->with('Основная информация', ['class' => 'col-lg-6'])
-                 ->add('main_characteristics', TableMainCharacteristicsType::class, [
-                     'label' => 'Основные характеристики',
-                     'help' => 'Введите данные в таблицу',
-                     'attr' => [
-                         'style' => 'display: grid;
-                                     grid-template-columns: 1fr 1fr 1fr 1fr;
-                                     gap: 20px;',
-                     ]
-                 ])
-                 ->end()
-                 ->with('Основная информация', ['class' => 'col-lg-6'])
-                 ->add('interesting_image', MediaType::class, [
-                     'label' => 'Основное изображение "Вас це може зацікавити"',
-                     'required' => false,
-                     'provider' => 'sonata.media.provider.image',
-                     'context'  => 'dc_site'
-                 ])
-                 ->add('interesting', InterestingType::class, [
-                     'label' => 'Вас це може зацікавити',
-                     'help' => '<hr style="margin: 20px 0; border: 1px solid #ddd;">'
-                 ])
-                 ->end();
-             ;
-         }
-     }
- }
-