mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-03 06:54:34 +02:00
Added very basic possibility to add an association
This commit is contained in:
parent
b7cfdebad5
commit
8ab9cf1417
8 changed files with 143 additions and 6 deletions
57
src/Form/Part/PartAssociationType.php
Normal file
57
src/Form/Part/PartAssociationType.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 - 2023 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace App\Form\Part;
|
||||
|
||||
use App\Entity\Parts\AssociationType;
|
||||
use App\Entity\Parts\PartAssociation;
|
||||
use App\Form\Type\PartSelectType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EnumType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class PartAssociationType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('type', EnumType::class, [
|
||||
'class' => AssociationType::class,
|
||||
])
|
||||
->add('other', PartSelectType::class)
|
||||
->add('comment', TextType::class, [
|
||||
'required' => false,
|
||||
])
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => PartAssociation::class,
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -245,6 +245,16 @@ class PartBaseType extends AbstractType
|
|||
],
|
||||
]);
|
||||
|
||||
//Part associations
|
||||
$builder->add('associated_parts_as_owner', CollectionType::class, [
|
||||
'entry_type' => PartAssociationType::class,
|
||||
'allow_add' => true,
|
||||
'allow_delete' => true,
|
||||
'reindex_enable' => true,
|
||||
'label' => false,
|
||||
'by_reference' => false,
|
||||
]);
|
||||
|
||||
$builder->add('log_comment', TextType::class, [
|
||||
'label' => 'edit.log_comment',
|
||||
'mapped' => false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue