THELIA Forum

Welcome to the THELIA support and discusssion forum

Offline


J'ai commencé à créer une page pour mettre à jour les image  d'un vendeur de la marketplace.
J'ai l'impression d'avoir tout bien fait mais j'ai cette erreur :

InvalidArgumentException in FormRegistry.php line 92:
Could not load type "seller_image_id"

in FormRegistry.php line 92
at FormRegistry->getType('seller_image_id') in FormFactory.php line 107
at FormFactory->createNamedBuilder('id', 'seller_image_id', null, array()) in FormBuilder.php line 106
at FormBuilder->create('id', 'seller_image_id', array()) in FormBuilder.php line 267
at FormBuilder->resolveChildren() in FormBuilder.php line 215
at FormBuilder->getForm() in BaseForm.php line 210
at BaseForm->__construct(object(Request), 'form', array(), array(), object(CoreDevDebugProjectContainer)) in TheliaFormFactory.php line 56
at TheliaFormFactory->createForm('seller_image.update') in Form.php line 131
at Form->generateForm(array('name' => 'seller_image.update'), null, object(Smarty_Internal_Template), true) in smarty_internal_templatebase.php(171) : eval()'d code line 276
at content_5b17d2e44ab0a6_24634684(object(Smarty_Internal_Template)) in smarty_internal_templatebase.php line 188
at Smarty_Internal_TemplateBase->fetch('file:seller-image-edit.html') in SmartyParser.php line 381
at SmartyParser->internalRenderer('file', 'seller-image-edit.html', array('seller_image_id' => '3', 'redirectUrl' => '/admin/module/artabanmarketplace/seller/edit?seller_id=1', 'edit_language_id' => '1', 'edit_language_locale' => 'fr_FR', 'edit_currency_id' => '1', 'locale' => 'fr_FR', 'lang_code' => 'fr', 'lang_id' => '1', 'current_url' => 'http://localhost/theliaArtabanMarketplace/web/index_dev.php/admin/module/artabanmarketplace/seller_image/edit?seller_image_id=3', 'app' => object(stdClass)), true) in SmartyParser.php line 424
at SmartyParser->render('seller-image-edit.html', array('seller_image_id' => '3', 'redirectUrl' => '/admin/module/artabanmarketplace/seller/edit?seller_id=1', 'edit_language_id' => '1', 'edit_language_locale' => 'fr_FR', 'edit_currency_id' => '1', 'locale' => 'fr_FR', 'lang_code' => 'fr', 'lang_id' => '1', 'current_url' => 'http://localhost/theliaArtabanMarketplace/web/index_dev.php/admin/module/artabanmarketplace/seller_image/edit?seller_image_id=3', 'app' => object(stdClass))) in BaseAdminController.php line 390
at BaseAdminController->renderRaw('seller-image-edit.html', array('seller_image_id' => '3', 'redirectUrl' => '/admin/module/artabanmarketplace/seller/edit?seller_id=1', 'edit_language_id' => '1', 'edit_language_locale' => 'fr_FR', 'edit_currency_id' => '1')) in BaseAdminController.php line 346
at BaseAdminController->render('seller-image-edit', array('seller_image_id' => '3', 'redirectUrl' => '/admin/module/artabanmarketplace/seller/edit?seller_id=1')) in SellerImageController.php line 58
at SellerImageController->updateAction()
at call_user_func_array(array(object(SellerImageController), 'updateAction'), array()) in HttpKernel.php line 139
at HttpKernel->handleRaw(object(Request), '1') in HttpKernel.php line 62
at HttpKernel->handle(object(Request), '1', true) in TheliaHttpKernel.php line 76
at TheliaHttpKernel->handle(object(Request), '1', true) in ParamInitMiddleware.php line 87
at ParamInitMiddleware->handle(object(Request), '1', true) in SessionMiddleware.php line 80
at SessionMiddleware->handle(object(Request), '1', true) in StackedHttpKernel.php line 23
at StackedHttpKernel->handle(object(Request), '1', true) in Kernel.php line 185
at Kernel->handle(object(Request)) in index_dev.php line 36

Est ce que quelqu'un aurait une piste ?
Si il faut des infos sur ce que j'ai fait, demandez, je mettrais mon code.
Merci d'avance.

Last edited by GillesL (06-06-2018 13:58:37)

Offline


Tu as du inverser nom du champ (seller_image_id) et type du champ (file) dans la méthode buildForm() de la form seller_image.update :

        $this->formBuilder
            ->add(
                'seller_image_id',
                'file',
                [
                ...

CQFDev | Sites, boutiques, modules, développement et intégration pour Thelia 1 et 2

Offline


Merci.
En fait dans mon code, largement inspiré du module "Diaporamas" j'avais

        $this->formBuilder
            ->add("id", SellerImageIdType::TYPE_NAME)
            ->add("seller_id", SellerIdType::TYPE_NAME)

En voyant ton code, j'ai mis

        $this->formBuilder
            ->add("id")
            ->add("seller_id")

Et le formulaire est apparu !

Je vais m'amuser avec pour le faire fonctionner !

Encore merci !

Offline


Bon !
Ca se débloque !

Je n'avait pas déclaré les services des types.

ArtabanMarketplace\Config\config.xml

....
        <service id="ArtabanMarketplace.form.type.seller_id" class="ArtabanMarketplace\Form\Type\SellerIdType">
            <argument id="thelia.translator" type="service"/>
            <tag name="thelia.form.type"/>
        </service>
        <service id="ArtabanMarketplace.form.type.seller_image_id" class="ArtabanMarketplace\Form\Type\SellerImageIdType">
            <argument id="thelia.translator" type="service"/>
            <tag name="thelia.form.type"/>
        </service>
...

ArtabanMarketplace\Form\SellerImageUpdateForm.php

....
namespace ArtabanMarketplace\Form;

use ArtabanMarketplace\Form\Type\SellerIdType;
use ArtabanMarketplace\Form\Type\SellerImageIdType;
use Thelia\Form\Image\ImageModification;

/**
 * Class SellerImageUpdateForm
 * @package ArtabanMarketplace\Form
 */
class SellerImageUpdateForm extends ImageModification
{
    const FORM_NAME = "seller_image_update";

    public function getName()
    {
        return static::FORM_NAME;
    }

    public function buildForm()
    {
        parent::buildForm();
        $this->formBuilder
            ->add("id", SellerImageIdType::TYPE_NAME)
            ->add("seller_id", SellerIdType::TYPE_NAME)
        ;
    }
}

Et le formulaire s'affiche !

Bon, maintenant, il ne reste plus qu'à gérer les services pour que le formulaire mette effectivement les données à jour.