Admin panels

This commit is contained in:
Frank van den Berg
2026-06-27 15:53:43 +02:00
parent 0d8335dd2c
commit ac57385a9d
17 changed files with 997 additions and 88 deletions
+58
View File
@@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
namespace App\Tech\Form;
use App\Tech\Entity\User;
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\EmailType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
class AdminUserType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('email', EmailType::class, [
'constraints' => [new NotBlank(), new Email()],
])
->add('username', TextType::class, [
'constraints' => [new NotBlank(), new Length(min: 2, max: 180)],
])
->add('plainPassword', PasswordType::class, [
'mapped' => false,
'required' => false,
'label' => 'New password',
'attr' => ['autocomplete' => 'new-password', 'placeholder' => 'Leave blank to keep current'],
])
->add('roles', ChoiceType::class, [
'choices' => [
'Player' => 'ROLE_PLAYER',
'Admin' => 'ROLE_ADMIN',
],
'multiple' => true,
'expanded' => true,
'label' => 'Roles',
])
->add('isVerified', CheckboxType::class, [
'required' => false,
'label' => 'Email verified',
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => User::class,
]);
}
}