mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-03-10 09:18:33 +01:00
Added possibility to add/edit attachments on Admin pages.
This commit is contained in:
@@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user