CK Editor for FAQ of SyliusCmsPlugin


#1

I’m trying to put a CK Editor on the field ‘answer’ of the FAQ of SyliusCmsPlugin.

src\AppBundle\Form\Extension\FrequentlyAskedQuestionTranslationTypeExtension.php

<?php

declare(strict_types=1);

namespace AppBundle\Form\Extension;

use Ivory\CKEditorBundle\Form\Type\CKEditorType;
use BitBag\SyliusCmsPlugin\Form\Type\Translation\FrequentlyAskedQuestionTranslationType;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormBuilderInterface;

 final class FrequentlyAskedQuestionTranslationTypeExtension extends AbstractTypeExtension
 {
     /**
      * {@inheritdoc}
      */
     public function buildForm(FormBuilderInterface $builder, array $options): void
     {
         $builder
            ->remove('answer')
            ->add('answer', CKEditorType::class)
         ;
     }

     /**
      * {@inheritdoc}
      */
     public function getExtendedType(): string
    {
         return FrequentlyAskedQuestionTranslationType::class;
     }
}

app\config\services.yml

services:
    app.form.extension.product_translation:
        class: AppBundle\Form\Extension\ProductTranslationTypeExtension
        tags:
            - { name: form.type_extension, extended_type: 
 Sylius\Bundle\ProductBundle\Form\Type\ProductTranslationType, priority: -1 }
     app.form.extension.translation.frequently_asked_question:
         class: AppBundle\Form\Extension\FrequentlyAskedQuestionTranslationTypeExtension
        tags:
             - { name: form.type_extension, extended_type: 
  BitBag\SyliusCmsPlugin\Form\Type\Translation\FrequentlyAskedQuestionTranslationType, priority: -1 }

It works for the product description but not for the answer of a faq…

Any leads ?


#2

Finally It works with

app\config\services.yml

 services: ~

src\AppBundle\Resources\config\services.yml

services:
    app.form.extension.product_translation:
        class: AppBundle\Form\Extension\ProductTranslationTypeExtension
        tags:
            - { name: form.type_extension, extended_type: 
 Sylius\Bundle\ProductBundle\Form\Type\ProductTranslationType, priority: -1 }
     app.form.translation.extension.frequently_asked_question:
        class: AppBundle\Form\Extension\FrequentlyAskedQuestionTranslationTypeExtension
         tags:
             - { name: form.type_extension, extended_type: 
 BitBag\SyliusCmsPlugin\Form\Type\Translation\FrequentlyAskedQuestionTranslationType, priority: -1 }

C:\wamp64\www\sylius3\src\AppBundle\Form\Extension\FrequentlyAskedQuestionTranslationTypeExtension.php

 <?php

declare(strict_types=1);

 namespace AppBundle\Form\Extension;

 use Ivory\CKEditorBundle\Form\Type\CKEditorType;
 use BitBag\SyliusCmsPlugin\Form\Type\Translation\FrequentlyAskedQuestionTranslationType;
 use Symfony\Component\Form\AbstractTypeExtension;
 use Symfony\Component\Form\FormBuilderInterface;

 final class FrequentlyAskedQuestionTranslationTypeExtension extends AbstractTypeExtension
 {
     /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options): void
     {
         $builder
             ->remove('answer')
             ->add('answer', CKEditorType::class)
         ;
      }

     /**
       * {@inheritdoc}
      */
     public function getExtendedType(): string
     {
          return FrequentlyAskedQuestionTranslationType::class;
      }
 }