mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-30 13:34:28 +02:00
Added possibility to add/edit attachments on Admin pages.
This commit is contained in:
parent
97cb91a3b2
commit
eb1d8fd4e4
28 changed files with 247 additions and 25 deletions
|
@ -44,6 +44,7 @@ use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\LanguageType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
|
@ -52,6 +53,7 @@ use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
|||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TimezoneType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Validator\Constraints\Length;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
@ -68,6 +70,11 @@ class UserAdminForm extends AbstractType
|
|||
$this->trans = $trans;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
parent::configureOptions($resolver); // TODO: Change the autogenerated stub
|
||||
$resolver->setRequired('attachment_class');
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
|
@ -182,6 +189,18 @@ class UserAdminForm extends AbstractType
|
|||
|
||||
$this->additionalFormElements($builder, $options, $entity);
|
||||
|
||||
//Attachment section
|
||||
$builder->add('attachments', CollectionType::class, [
|
||||
'entry_type' => AttachmentFormType::class,
|
||||
'allow_add' => true,
|
||||
'allow_delete' => true,
|
||||
'label' => false,
|
||||
'entry_options' => [
|
||||
'data_class' => $options['attachment_class'],
|
||||
],
|
||||
'by_reference' => false
|
||||
]);
|
||||
|
||||
//Buttons
|
||||
$builder->add('save', SubmitType::class, [
|
||||
'label' => $is_new ? $this->trans->trans('user.create') : $this->trans->trans('user.edit.save'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue