Jump to content

Edit History

ps8modules

ps8modules

This hook is for override !!!

Remove field from hook hookActionProductFormBuilderModifier and add new:

use Language;
use PrestaShop\PrestaShop\Adapter\Category\CategoryDataProvider;
use PrestaShop\PrestaShop\Adapter\Configuration;
use PrestaShop\PrestaShop\Adapter\Feature\FeatureDataProvider;
use PrestaShop\PrestaShop\Adapter\LegacyContext;
use PrestaShop\PrestaShop\Adapter\Manufacturer\ManufacturerDataProvider;
use PrestaShop\PrestaShop\Adapter\Product\ProductDataProvider;
use PrestaShop\PrestaShop\Core\Domain\Product\ProductSettings;
use PrestaShopBundle\Form\Admin\Category\SimpleCategory;
use PrestaShopBundle\Form\Admin\Feature\ProductFeature;
use PrestaShopBundle\Form\Admin\Type\ChoiceCategoriesTreeType;
use PrestaShopBundle\Form\Admin\Type\CommonAbstractType;
use PrestaShopBundle\Form\Admin\Type\FormattedTextareaType;
use PrestaShopBundle\Form\Admin\Type\TranslateType;
use PrestaShopBundle\Form\Admin\Type\TypeaheadProductCollectionType;
use PrestaShopBundle\Form\Admin\Type\TypeaheadProductPackCollectionType;
use PrestaShopBundle\Form\Validator\Constraints\TinyMceMaxLength;
use PrestaShopBundle\Service\Routing\Router;
use Symfony\Component\Form\Extension\Core\Type as FormType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\Constraints as Assert;

class my_module extends Module {

    public function __construct()
    {
        ...
        ...
    }

    public function install()
    {
        ...
        $this->registerHook('actionProductFormBuilderModifier');
    }

    public function uninstall()
    {
        ...
        $this->unregisterHook('actionProductFormBuilderModifier');
    }

    public function hookActionProductFormBuilderModifier($params)
    {
        $formBuilder = $params['form_builder'];

        $formBuilder->remove('name'); // remove old name input

        // create new name filed
        $formBuilder->add('name', TranslatableType::class, [
            'type' => FormType\TextType::class,
            'options' => [
                    'constraints' => [
                        new Assert\NotBlank(),
                        new Assert\Length(['min' => 3, 'max' => 128]),
                    ],
                    'attr' => [
                        'placeholder' => $this->translator->trans('Enter your product name', [], 'Admin.Catalog.Help'),
                        'class' => 'edit js-edit serp-default-title',
                    ],
                ],
          ]);
    }

}

 

ps8modules

ps8modules

remove field fom hook hookActionProductFormBuilderModifier and add new:

use Language;
use PrestaShop\PrestaShop\Adapter\Category\CategoryDataProvider;
use PrestaShop\PrestaShop\Adapter\Configuration;
use PrestaShop\PrestaShop\Adapter\Feature\FeatureDataProvider;
use PrestaShop\PrestaShop\Adapter\LegacyContext;
use PrestaShop\PrestaShop\Adapter\Manufacturer\ManufacturerDataProvider;
use PrestaShop\PrestaShop\Adapter\Product\ProductDataProvider;
use PrestaShop\PrestaShop\Core\Domain\Product\ProductSettings;
use PrestaShopBundle\Form\Admin\Category\SimpleCategory;
use PrestaShopBundle\Form\Admin\Feature\ProductFeature;
use PrestaShopBundle\Form\Admin\Type\ChoiceCategoriesTreeType;
use PrestaShopBundle\Form\Admin\Type\CommonAbstractType;
use PrestaShopBundle\Form\Admin\Type\FormattedTextareaType;
use PrestaShopBundle\Form\Admin\Type\TranslateType;
use PrestaShopBundle\Form\Admin\Type\TypeaheadProductCollectionType;
use PrestaShopBundle\Form\Admin\Type\TypeaheadProductPackCollectionType;
use PrestaShopBundle\Form\Validator\Constraints\TinyMceMaxLength;
use PrestaShopBundle\Service\Routing\Router;
use Symfony\Component\Form\Extension\Core\Type as FormType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\Constraints as Assert;

class my_module extends Module {

    public function __construct()
    {
        ...
        ...
    }

    public function install()
    {
        ...
        $this->registerHook('actionProductFormBuilderModifier');
    }

    public function uninstall()
    {
        ...
        $this->unregisterHook('actionProductFormBuilderModifier');
    }

    public function hookActionProductFormBuilderModifier($params)
    {
        $formBuilder = $params['form_builder'];

        $formBuilder->remove('name'); // remove old name input

        // create new name filed
        $formBuilder->add('name', TranslatableType::class, [
            'type' => FormType\TextType::class,
            'options' => [
                    'constraints' => [
                        new Assert\NotBlank(),
                        new Assert\Length(['min' => 3, 'max' => 128]),
                    ],
                    'attr' => [
                        'placeholder' => $this->translator->trans('Enter your product name', [], 'Admin.Catalog.Help'),
                        'class' => 'edit js-edit serp-default-title',
                    ],
                ],
          ]);
    }

}

 

ps8modules

ps8modules

remove field fom hook hookActionProductFormBuilderModifier and add new:

use Symfony\Component\Form\Extension\Core\Type as FormType;
use PrestaShopBundle\Form\Admin\Type\FormattedTextareaType;
use PrestaShopBundle\Form\Admin\Type\TranslateType;

class my_module extends Module {

    public function __construct()
    {
        ...
        ...
    }

    public function install()
    {
        ...
        $this->registerHook('actionProductFormBuilderModifier');
    }

    public function uninstall()
    {
        ...
        $this->unregisterHook('actionProductFormBuilderModifier');
    }

    public function hookActionProductFormBuilderModifier($params)
    {
        $formBuilder = $params['form_builder'];

        $formBuilder->remove('name'); // remove old name input

        // create new name filed
        $formBuilder->add('name', TranslatableType::class, [
            'type' => FormType\TextType::class,
            'options' => [
                    'constraints' => [
                        new Assert\NotBlank(),
                        new Assert\Length(['min' => 3, 'max' => 128]),
                    ],
                    'attr' => [
                        'placeholder' => $this->translator->trans('Enter your product name', [], 'Admin.Catalog.Help'),
                        'class' => 'edit js-edit serp-default-title',
                    ],
                ],
          ]);
    }

}

 

×
×
  • Create New...