diff --git a/src/Entity/Attachments/AttachmentContainingDBElement.php b/src/Entity/Attachments/AttachmentContainingDBElement.php index 8160e9c7..d3434161 100644 --- a/src/Entity/Attachments/AttachmentContainingDBElement.php +++ b/src/Entity/Attachments/AttachmentContainingDBElement.php @@ -53,8 +53,10 @@ declare(strict_types=1); namespace App\Entity\Attachments; use App\Entity\Base\NamedDBElement; +use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Doctrine\ORM\PersistentCollection; use Exception; /** @@ -74,6 +76,11 @@ abstract class AttachmentContainingDBElement extends NamedDBElement //TODO protected $attachmentTypes; + public function __construct() + { + $this->attachments = new ArrayCollection(); + } + /******************************************************************************** * * Getters diff --git a/src/Entity/Parts/Part.php b/src/Entity/Parts/Part.php index df4b794c..5fc607a6 100644 --- a/src/Entity/Parts/Part.php +++ b/src/Entity/Parts/Part.php @@ -67,6 +67,8 @@ use App\Entity\Devices\Device; use App\Entity\PriceInformations\Orderdetail; use App\Security\Annotations\ColumnSecurity; use App\Validator\Constraints\Selectable; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\PersistentCollection; @@ -167,7 +169,7 @@ class Part extends AttachmentContainingDBElement * * @ColumnSecurity(prefix="name") */ - protected $name; + protected $name = ''; /** * @var string @@ -239,7 +241,7 @@ class Part extends AttachmentContainingDBElement * @ORM\Column(type="string") * @ColumnSecurity(prefix="manufacturer", type="string", placeholder="") */ - protected $manufacturer_product_number; + protected $manufacturer_product_number = ''; /** * @var bool Determines if this part entry needs review (for example, because it is work in progress) @@ -258,7 +260,7 @@ class Part extends AttachmentContainingDBElement * @var string A comma seperated list of tags, assocciated with the part. * @ORM\Column(type="text") */ - protected $tags; + protected $tags = ''; /** * @var float|null How much a single part unit weighs in gramms. @@ -267,6 +269,12 @@ class Part extends AttachmentContainingDBElement */ protected $mass; + public function __construct() + { + parent::__construct(); + $this->partLots = new ArrayCollection(); + } + /** * Returns the ID as an string, defined by the element class. * This should have a form like P000014, for a part with ID 14. @@ -473,7 +481,7 @@ class Part extends AttachmentContainingDBElement * * the array is sorted by the suppliers names / minimum order quantity * */ - public function getOrderdetails(bool $hide_obsolete = false) : PersistentCollection + public function getOrderdetails(bool $hide_obsolete = false) : Collection { //If needed hide the obsolete entries if ($hide_obsolete) { @@ -587,9 +595,9 @@ class Part extends AttachmentContainingDBElement /** * Get all part lots where this part is stored. - * @return PartLot[]|PersistentCollection + * @return PartLot[]|Collection */ - public function getPartLots() : PersistentCollection + public function getPartLots() : Collection { return $this->partLots; } diff --git a/src/Form/Part/PartBaseType.php b/src/Form/Part/PartBaseType.php index ad8fe5bf..5730ae04 100644 --- a/src/Form/Part/PartBaseType.php +++ b/src/Form/Part/PartBaseType.php @@ -93,10 +93,10 @@ class PartBaseType extends AbstractType ->add('category', StructuralEntityType::class, ['class' => Category::class, 'label' => 'category.label', 'disable_not_selectable' => true, 'disabled' => !$this->security->isGranted('move', $part), ]) - ->add('footprint', StructuralEntityType::class, ['class' => Footprint::class, + ->add('footprint', StructuralEntityType::class, ['class' => Footprint::class, 'required' => false, 'label' => 'footprint.label', 'disable_not_selectable' => true, 'disabled' => !$this->security->isGranted('move', $part), ]) - ->add('tags', TextType::class, ['required' => false, 'label' => 'part.tags', + ->add('tags', TextType::class, ['required' => false, 'label' => 'part.tags', 'empty_data' => "", 'attr' => ['data-role' => 'tagsinput'], 'disabled' => !$this->security->isGranted('edit', $part) ]) ->add('comment', CKEditorType::class, ['required' => false,