mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-21 19:34:54 +02:00
Added a workaround for an symfony issue with collectiontype.
This commit is contained in:
parent
3021d0d67a
commit
54fa445f06
4 changed files with 36 additions and 3 deletions
|
@ -53,7 +53,7 @@ class CollectionTypeExtension extends AbstractTypeExtension
|
||||||
|
|
||||||
public static function getExtendedTypes(): iterable
|
public static function getExtendedTypes(): iterable
|
||||||
{
|
{
|
||||||
return [CollectionType::class];
|
return [CollectionType::class, WorkaroundCollectionType::class];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver): void
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
|
|
|
@ -47,6 +47,7 @@ use App\Entity\Parts\Supplier;
|
||||||
use App\Entity\PriceInformations\Orderdetail;
|
use App\Entity\PriceInformations\Orderdetail;
|
||||||
use App\Entity\PriceInformations\Pricedetail;
|
use App\Entity\PriceInformations\Pricedetail;
|
||||||
use App\Form\Type\StructuralEntityType;
|
use App\Form\Type\StructuralEntityType;
|
||||||
|
use App\Form\WorkaroundCollectionType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||||
|
@ -109,7 +110,7 @@ class OrderdetailType extends AbstractType
|
||||||
}
|
}
|
||||||
|
|
||||||
//Attachment section
|
//Attachment section
|
||||||
$event->getForm()->add('pricedetails', CollectionType::class, [
|
$event->getForm()->add('pricedetails', WorkaroundCollectionType::class, [
|
||||||
'entry_type' => PricedetailType::class,
|
'entry_type' => PricedetailType::class,
|
||||||
'allow_add' => $this->security->isGranted('@parts_prices.create'),
|
'allow_add' => $this->security->isGranted('@parts_prices.create'),
|
||||||
'allow_delete' => $this->security->isGranted('@parts_prices.delete'),
|
'allow_delete' => $this->security->isGranted('@parts_prices.delete'),
|
||||||
|
|
|
@ -56,6 +56,7 @@ use App\Form\ParameterType;
|
||||||
use App\Form\Type\MasterPictureAttachmentType;
|
use App\Form\Type\MasterPictureAttachmentType;
|
||||||
use App\Form\Type\SIUnitType;
|
use App\Form\Type\SIUnitType;
|
||||||
use App\Form\Type\StructuralEntityType;
|
use App\Form\Type\StructuralEntityType;
|
||||||
|
use App\Form\WorkaroundCollectionType;
|
||||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
|
@ -258,7 +259,7 @@ class PartBaseType extends AbstractType
|
||||||
]);
|
]);
|
||||||
|
|
||||||
//Orderdetails section
|
//Orderdetails section
|
||||||
$builder->add('orderdetails', CollectionType::class, [
|
$builder->add('orderdetails', WorkaroundCollectionType::class, [
|
||||||
'entry_type' => OrderdetailType::class,
|
'entry_type' => OrderdetailType::class,
|
||||||
'allow_add' => $this->security->isGranted('orderdetails.create', $part),
|
'allow_add' => $this->security->isGranted('orderdetails.create', $part),
|
||||||
'allow_delete' => $this->security->isGranted('orderdetails.delete', $part),
|
'allow_delete' => $this->security->isGranted('orderdetails.delete', $part),
|
||||||
|
|
31
src/Form/WorkaroundCollectionType.php
Normal file
31
src/Form/WorkaroundCollectionType.php
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace App\Form;
|
||||||
|
|
||||||
|
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||||
|
use Symfony\Component\Form\FormInterface;
|
||||||
|
use Symfony\Component\Form\FormView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This a workaround for the issue #37024.
|
||||||
|
* @package App\Form
|
||||||
|
*/
|
||||||
|
class WorkaroundCollectionType extends CollectionType
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use the original implementation for finishView() instead of the one, the one that cause the bug.
|
||||||
|
* @param FormView $view
|
||||||
|
* @param FormInterface $form
|
||||||
|
* @param array $options
|
||||||
|
*/
|
||||||
|
public function finishView(FormView $view, FormInterface $form, array $options)
|
||||||
|
{
|
||||||
|
if ($view->vars['prototype']->vars['multipart']) {
|
||||||
|
$view->vars['multipart'] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue