I lowkey forgot to commit
This commit is contained in:
51
src/Form/ProfileFormType.php
Normal file
51
src/Form/ProfileFormType.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\User;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
class ProfileFormType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('email', EmailType::class, [
|
||||
'constraints' => [new Assert\NotBlank(), new Assert\Email()],
|
||||
])
|
||||
->add('displayName', TextType::class, [
|
||||
'required' => false,
|
||||
'constraints' => [new Assert\Length(max: 120)],
|
||||
])
|
||||
->add('currentPassword', PasswordType::class, [
|
||||
'mapped' => false,
|
||||
'required' => false,
|
||||
'label' => 'Current password (required to change password)'
|
||||
])
|
||||
->add('newPassword', RepeatedType::class, [
|
||||
'type' => PasswordType::class,
|
||||
'mapped' => false,
|
||||
'required' => false,
|
||||
'first_options' => ['label' => 'New password (optional)'],
|
||||
'second_options' => ['label' => 'Repeat new password'],
|
||||
'invalid_message' => 'The password fields must match.',
|
||||
'constraints' => [new Assert\Length(min: 8)],
|
||||
]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => User::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
53
src/Form/RegistrationFormType.php
Normal file
53
src/Form/RegistrationFormType.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\User;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
class RegistrationFormType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('email', EmailType::class, [
|
||||
'required' => true,
|
||||
'constraints' => [new Assert\NotBlank(), new Assert\Email()],
|
||||
])
|
||||
->add('displayName', TextType::class, [
|
||||
'required' => false,
|
||||
'constraints' => [new Assert\Length(max: 120)],
|
||||
])
|
||||
->add('plainPassword', RepeatedType::class, [
|
||||
'type' => PasswordType::class,
|
||||
'mapped' => false,
|
||||
'first_options' => ['label' => 'Password'],
|
||||
'second_options' => ['label' => 'Repeat Password'],
|
||||
'invalid_message' => 'The password fields must match.',
|
||||
'constraints' => [
|
||||
new Assert\NotBlank(groups: ['registration']),
|
||||
new Assert\Length(min: 8, groups: ['registration']),
|
||||
],
|
||||
])
|
||||
->add('register', SubmitType::class, [
|
||||
'label' => 'Create account',
|
||||
]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => User::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
46
src/Form/ReviewType.php
Normal file
46
src/Form/ReviewType.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Review;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\RangeType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
class ReviewType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('title', TextType::class, [
|
||||
'constraints' => [new Assert\NotBlank(), new Assert\Length(max: 160)],
|
||||
])
|
||||
->add('content', TextareaType::class, [
|
||||
'constraints' => [new Assert\NotBlank(), new Assert\Length(min: 20, max: 5000)],
|
||||
'attr' => ['rows' => 8],
|
||||
])
|
||||
->add('rating', RangeType::class, [
|
||||
'constraints' => [new Assert\Range(min: 1, max: 10)],
|
||||
'attr' => [
|
||||
'min' => 1,
|
||||
'max' => 10,
|
||||
'step' => 1,
|
||||
'class' => 'form-range',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Review::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
33
src/Form/SiteSettingsType.php
Normal file
33
src/Form/SiteSettingsType.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class SiteSettingsType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('SPOTIFY_CLIENT_ID', TextType::class, [
|
||||
'required' => false,
|
||||
'label' => 'Spotify Client ID',
|
||||
'mapped' => false,
|
||||
])
|
||||
->add('SPOTIFY_CLIENT_SECRET', TextType::class, [
|
||||
'required' => false,
|
||||
'label' => 'Spotify Client Secret',
|
||||
'mapped' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user