compsoul.dev Posted October 16, 2023 Share Posted October 16, 2023 <?php declare(strict_types=1); namespace PrestaShop\Module\CompsoulCategories\Form; use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType; use PrestaShopBundle\Form\Admin\Type\CategoryChoiceTreeType; use Symfony\Component\Form\FormBuilderInterface; class ConfigurationFormType extends TranslatorAwareType { public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('category_ids', CategoryChoiceTreeType::class, [ 'label' => $this->trans('Category choice', 'Modules.CompsoulCategories.Admin'), ]); } } Too few arguments to function PrestaShopBundle\Form\Admin\Type\TranslatorAwareType::__construct(), 0 passed in D:\wamp64\www\skate\vendor\symfony\symfony\src\Symfony\Component\Form\FormRegistry.php on line 89 and exactly 2 expected Link to comment Share on other sites More sharing options...
bam_nico Posted October 30, 2023 Share Posted October 30, 2023 Hi, I have the same problem do you find a solution ? Thanks Link to comment Share on other sites More sharing options...
compsoul.dev Posted October 30, 2023 Author Share Posted October 30, 2023 I forgot what I did Probably clearing (deleting everything) from the folder helped: \var\cache Now my code looks like this: declare(strict_types=1); namespace PrestaShop\Module\CompsoulCategories\Form; use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType; use PrestaShopBundle\Form\Admin\Type\TranslatableType; use PrestaShopBundle\Form\Admin\Type\FormattedTextareaType; use PrestaShopBundle\Form\Admin\Type\CategoryChoiceTreeType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; class Form extends TranslatorAwareType { public function buildForm(FormBuilderInterface $builder, array $options): void { $builder ->add('category_heading', TranslatableType::class, [ 'label' => $this->trans('Section heading', 'Modules.CompsoulCategories.Admin'), 'type' => TextType::class, 'required' => false, ]) ->add('category_content', TranslatableType::class, [ 'label' => $this->trans('Section description', 'Modules.CompsoulCategories.Admin'), 'type' => FormattedTextareaType::class, 'required' => false, ]) ->add('category_ids', CategoryChoiceTreeType::class, [ 'label' => 'Category', 'multiple' => true, ]) ; } } Link to comment Share on other sites More sharing options...
Houssem MAAMRIA Posted February 25, 2024 Share Posted February 25, 2024 (edited) You have the option to use 'class ConfigurationFormType extends AbstractType...' instead of 'class ConfigurationFormType extends TranslatorAwareType...'. However, if you opt to use 'TranslatorAwareType', you must inject the translation service into your custom type:you_module/config/services.yaml services: _defaults: public: true you_module.form.type.custom_form_type: class: PrestaShop\Module\Custom\Form\ConfigurationFormType parent: 'form.type.translatable.aware' public: true arguments: - "@router" - "@=service('prestashop.adapter.legacy.configuration').getBoolean('PS_REWRITING_SETTINGS')" - "@=service('prestashop.adapter.legacy.configuration').getBoolean('PS_FORCE_FRIENDLY_PRODUCT')" - '@prestashop.adapter.legacy.context' - '@PrestaShop\PrestaShop\Core\ConfigurationInterface' tags: - { name: form.type } In your custom form class, retrieve it in the constructor method like this examle: <?php namespace YouModule\Custom\Form\Type; use PrestaShop\PrestaShop\Adapter\LegacyContext; use PrestaShop\PrestaShop\Core\ConfigurationInterface; use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType; use PrestaShopBundle\Translation\TranslatorInterface; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Routing\RouterInterface; class SeoEnhanceFieldType extends TranslatorAwareType { /** * @var RouterInterface */ private $router; /** * @var bool */ private $friendlyUrlEnabled; /** * @var bool */ private $forceFriendlyUrl; /** * @var LegacyContext */ private $legacyContext; /** * @var ConfigurationInterface */ private $configuration; /** * @param TranslatorInterface $translator * @param array $locales * @param RouterInterface $router * @param bool $friendlyUrlEnabled * @param bool $forceFriendlyUrl * @param LegacyContext $legacyContext * @param ConfigurationInterface $configuration */ public function __construct( TranslatorInterface $translator, array $locales, RouterInterface $router, bool $friendlyUrlEnabled, bool $forceFriendlyUrl, LegacyContext $legacyContext, ConfigurationInterface $configuration ) { parent::__construct($translator, $locales); $this->router = $router; $this->friendlyUrlEnabled = $friendlyUrlEnabled; $this->forceFriendlyUrl = $forceFriendlyUrl; $this->legacyContext = $legacyContext; $this->configuration = $configuration; } public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('customField', TextType::class, [ 'label' => 'Custom Field', 'data_class' => null, ]); } // your logique here } Edited February 25, 2024 by Maamria (see edit history) Link to comment Share on other sites More sharing options...
malcek Posted July 23, 2024 Share Posted July 23, 2024 Hello i have same problem when after migration proces from 1.7.8.11 shop to 8.1.5 (migrationPro module) Too few arguments to function PrestaShopBundle\Form\Admin\Type\TranslatorAwareType::__construct(), 0 passed in /mnt/home2/mydomainaccount/public_html/vendor/symfony/symfony/src/Symfony/Component/Form/FormRegistry.php on line 89 and exactly 2 expected [ArgumentCountError 0] How to find solution for that. I have big shop with 25000 product, over 18k orders, so i have to resolve this 😥 Link to comment Share on other sites More sharing options...
compsoul.dev Posted July 23, 2024 Author Share Posted July 23, 2024 Did you remove everything from the var/cache folder? This error doesn't say anything. I wish I could help you but I can't replicate it, in my case it stopped after recompiling the module or I guess after clearing the cache. Link to comment Share on other sites More sharing options...
masterwebsite Posted October 7, 2024 Share Posted October 7, 2024 Hi, did you find a solution for this error? Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now