Thanks for the answer, I had the issue fixed on my own, and i forgot to put
the answer here. Anyway thank you so much, and good luck to you too!
Le jeudi 14 juillet 2016 15:18:28 UTC+2, Lorenzo Sanzari a écrit :
>
> I had the same problem.
>
> The reason is that in the
> vendor\sonata-project\ecommerce\src\ProductBundle\Model\BaseProductProvider.php
>
> ,in the buildEditForm() method we have (from row 508):
>
> $formMapper->add('image', 'sonata_type_model_list',
> array(
> 'required' => false,
> ),
> array(
> 'link_parameters' => array(
> 'context' => 'product_catalog',
> 'filter' => array('context' => array('value' =>
> 'product_catalog')),
> 'provider' => '', // <--- HERE IS THE PROBLEM!!!!
> ),
> ));
>
> Same thing for gallery:
>
> $formMapper->add('gallery', 'sonata_type_model_list',
> array(
> 'required' => false,
> ),
> array(
> 'link_parameters' => array(
> 'context' => 'product_catalog',
> 'filter' => array('context' => array('value' =>
> 'product_catalog')),
> 'provider' => '', // <--- HERE IS THE
> PROBLEM!!!!
> ),
> ));
>
> To solve the issue, you can override the buildEditForm() method in your
> src\Application\Sonata\ProductBundle\Provider\DummyProductProvider.php as
> follow:
>
> public function buildEditForm(FormMapper $formMapper, $isVariation = false)
> {
> $formMapper->with('Product');
>
> $formMapper->add('enabled');
>
> $formMapper->add('name');
> $formMapper->add('sku');
>
> $formMapper
> ->add('price', 'number')
> ->add('priceIncludingVat')
> ->add('vatRate', 'number')
> ->add('stock', 'integer')
> ;
>
> if (!$isVariation || in_array('description',
> $this->variationFields)) {
> $formMapper->add('description', 'sonata_formatter_type',
> array(
> 'source_field' => 'rawDescription',
> 'source_field_options' => array('attr' => array('class' =>
> 'span10',
> 'rows' => 20)),
> 'format_field' => 'descriptionFormatter',
> 'target_field' => 'description',
> 'event_dispatcher' =>
> $formMapper->getFormBuilder()->getEventDispatcher(),
> ));
> }
>
> if (!$isVariation || in_array('short_description',
> $this->variationFields)) {
> $formMapper->add('shortDescription', 'sonata_formatter_type',
> array(
> 'source_field' => 'rawShortDescription',
> 'source_field_options' => array('attr' => array('class' =>
> 'span10',
> 'rows' => 20)),
> 'format_field' => 'shortDescriptionFormatter',
> 'target_field' => 'shortDescription',
> 'event_dispatcher' =>
> $formMapper->getFormBuilder()->getEventDispatcher(),
> ));
> }
>
> $formMapper->end();
>
> if (!$isVariation || in_array('image', $this->variationFields) ||
> in_array('gallery',
> $this->variationFields)) {
> $formMapper->with('Media');
>
> if (!$isVariation || in_array('image',
> $this->variationFields)) {
> $formMapper->add('image', 'sonata_type_model_list',
> array(
> 'required' => false,
> ),
> array(
> 'link_parameters' => array(
> 'context' => 'product_catalog',
> 'filter' => array('context' => array('value' =>
> 'product_catalog')),
> 'provider' => 'sonata.media.provider.image', //
> <--- HERE THE SOLUTION!!!
> ),
> ));
> }
>
> if (!$isVariation || in_array('gallery',
> $this->variationFields)) {
> $formMapper->add('gallery', 'sonata_type_model_list',
> array(
> 'required' => false,
> ),
> array(
> 'link_parameters' => array(
> 'context' => 'product_catalog',
> 'filter' => array('context' => array('value' =>
> 'product_catalog')),
> 'provider' => 'sonata.media.provider.image', //
> <--- HERE THE SOLUTION!!!
> ),
> ));
> }
>
> $formMapper->end();
> }
>
> }
>
>
> I suggest to you override also the buildCreateForm() method, as follow:
>
> public function buildCreateForm(FormMapper $formMapper)
> {
> $this->buildEditForm($formMapper);
> }
>
>
> I hope it will help to you! Good luck! ;-)
>
>
>
> Il giorno lunedì 6 giugno 2016 21:22:29 UTC+2, Aymeric Wilke ha scritto:
>>
>> Hi,
>>
>> I have a very simple (I think) issue.
>>
>> Han I add or modify a product in the admin side of eCommerce bundle, I
>> cannot add an image via the Ajax form :
>>
>>
>> <https://lh3.googleusercontent.com/-7nInvivdYbs/V1XNRJgrs7I/AAAAAAAADj8/lGdZ3zhMDDIaf9FdOsCoMagt9w4M4Ad3ACLcB/s1600/Capture%2Bd%25E2%2580%2599e%25CC%2581cran%2B2016-06-04%2Ba%25CC%2580%2B13.07.42.png>
>>
>>
>> When I click "Add new", the modal window says :
>> Select media provider
>>
>>
>> No provider available
>>
>>
>> I think the problem is from the link in the "Add new button". The link is
>> :
>> <a
>> href="/admin/sonata/media/media/create?*provider=&*context=product_catalog&filter%5Bcontext%5D%5Bvalue%5D=product_catalog&uniqid=s5752b747b03b8&code=sonata.media.admin.media&pcode=sonata.product.admin.product&puniqid=s5752b74755ebf"
>>
>> ……
>>
>>
>> And if I change it to add the provider like that :
>>
>> <a href="/admin/sonata/media/media/create?
>> *provider=sonata.media.provider.image*&context=product_catalog&filter%5Bcontext%5D%5Bvalue%5D=product_catalog&uniqid=s5752b747b03b8&code=sonata.media.admin.media&pcode=sonata.product.admin.product&puniqid=s5752b74755ebf"
>>
>> ……
>>
>> … it works perfect, and shows me the add image form.
>>
>> Could anyone know what is going on with that link ?
>> Many thanks in advance !
>>
>
--
You received this message because you are subscribed to the Google Groups
"sonata-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sonata-users.
For more options, visit https://groups.google.com/d/optout.