Add Enums and formtypes

This commit is contained in:
Ryan Prather 2024-12-08 17:07:54 -05:00
parent 1f82c8006f
commit 6bde369bcd
8 changed files with 383 additions and 0 deletions

11
src/Enums/GenderType.php Normal file
View File

@ -0,0 +1,11 @@
<?php
namespace App\Enums;
enum GenderType: string
{
case MALE = 'male';
case FEMALE = 'female';
case OTHER = 'other';
case TRANSGENDER = 'transgender';
}

20
src/Enums/RaceType.php Normal file
View File

@ -0,0 +1,20 @@
<?php
namespace App\Enums;
enum RaceType: string
{
case AFRICAN_AMERICAN = 'African American';
case AMERICAN_INDIANA = 'American Indian';
case ASIAN = 'Asian';
case ASIAN_PACIFIC = 'Asian/Pacific Islander';
case BIRACIAL = 'Biracial, Non-Hispanic';
case BLACK = 'Black, Non-Hispanic';
case CAUCASIAN = 'Caucasian';
case HISPANIC = 'Hispanic';
case MISSING_DATA = 'Missing Data';
case MULTIRACIAL = 'Multi-racial';
case NATIVE_AMERICAN = 'Native American';
case OTHER = 'Other';
case UNKNOWN = 'Unknown';
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Enums;
enum RelationshipType: string
{
case ADULT_CHILD = 'Adult Child';
case AUNT = 'Aunt';
case SO_OF_PARENT = 'Boy/Girlfriend of Parent';
case CAREGIVER = 'Caregiver';
case CHILD = 'Child';
case FATHER = 'Father';
case FOSTER_FATHER = 'Foster Father';
case FOSTER_MOTHER = 'Foster Mother';
case FOSTER_SIBLING = 'Foster Sibling';
case GRANDFATHER = 'Grandfather';
case GRANDMOTHER = 'Grandmother';
case HALF_SIBLING = 'Half Sibling';
case HOMESTUDY_PREPARATION = 'Homestudy Preparation';
case MOTHER = 'Mother';
case OTHER_RELATIVE = 'Other Relative';
case PARENT_PARAMOUR = 'Parent Paramour';
case SIBLING = 'Sibling';
case STEP_SIBLING = 'Step Sibling';
case STEP_FATHER = 'Stepfather';
case STEP_MOTHER = 'Stepmother';
case UNCLE = 'Uncle';
}

View File

@ -0,0 +1,59 @@
<?php
namespace App\Form;
use App\Entity\User;
use App\Enums\CaseLevel;
use App\Enums\JobType;
use App\Enums\RateType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class EditUserFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name', TextType::class, [
'required' => true,
'label' => 'Name',
'attr' => [
'class' => 'form-control',
'placeholder' => 'Name',
],
])
->add('email', EmailType::class, [
'required' => true,
'label' => 'Email',
'attr' => [
'class' => 'form-control',
'placeholder' => 'Email',
],
])
->add('caseWorker', CheckboxType::class)
->add('caseManager', CheckboxType::class)
->add('therapist', CheckboxType::class)
->add('su', CheckboxType::class, ['label' => 'Admin'])
->add('rateType', EnumType::class, [
'class' => RateType::class
])
->add('rate', NumberType::class)
->add('level', EnumType::class, [
'class' => CaseLevel::class,
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => User::class,
]);
}
}

View File

@ -0,0 +1,72 @@
<?php
namespace App\Form;
use App\Entity\MemberCase;
use App\Entity\ReferralSource;
use App\Enums\CaseLevel;
use App\Enums\County;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
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 MemberCaseFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('caseNumber', TextType::class, [
'required' => true
])
->add('firstName', TextType::class, [
'required' => true
])
->add('lastName', TextType::class, [
'required' => true
])
->add('referralType')
->add('admitDate', null, [
'widget' => 'single_text',
'required' => true,
])
->add('closeDate', null, [
'widget' => 'single_text',
])
->add('dcsCaseId', TextType::class, [
'required' => true
])
->add('insurance')
->add('medicaid')
->add('caseEmail')
->add('level', EnumType::class, [
'class' => CaseLevel::class,
])
->add('referralSource', EntityType::class, [
'class' => ReferralSource::class,
'choice_label' => 'name',
])
->add('referralSource2', EntityType::class, [
'class' => ReferralSource::class,
'choice_label' => 'name',
])
->add('address')
->add('address2')
->add('city')
->add('state')
->add('zip')
->add('county', EnumType::class, [
'class' => County::class,
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => MemberCase::class,
]);
}
}

View File

@ -0,0 +1,80 @@
<?php
namespace App\Form;
use App\Entity\Member;
use App\Enums\GenderType;
use App\Enums\RaceType;
use App\Enums\RelationshipType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class MemberFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('lastName', null, ['required' => true])
->add('firstName', null, ['required' => true])
->add('personalId', null, ['required' => true])
->add('dob', DateType::class, [
'widget' => 'single_text',
'required' => true
])
->add('emergencyContact')
->add('phone')
->add('dayPhone')
->add('eveningPhone')
->add('cellPhone')
->add('email', EmailType::class)
->add('school')
->add('address')
->add('city')
->add('state')
->add('zip')
->add('maritalStatus')
->add('relationship', EnumType::class, [
'class' => RelationshipType::class,
'required' => true
])
->add('gender', EnumType::class, [
'class' => GenderType::class,
'required' => true
])
->add('race', EnumType::class, [
'class' => RaceType::class
])
->add('language')
->add('isChild', CheckboxType::class, [
'mapped' => false
])
->add('isParent', CheckboxType::class, [
'mapped' => false
])
->add('isAdultChild', CheckboxType::class, [
'mapped' => false
])
->add('isLegalGuardian', CheckboxType::class, [
'mapped' => false
])
->add('parentsLiveTogether', CheckboxType::class, [
'mapped' => false
])
->add('dcsApproved', CheckboxType::class, [
'mapped' => false
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Member::class,
]);
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Form;
use App\Entity\User;
use App\Entity\UserCase;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class UserCaseFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('user', EntityType::class, [
'class' => User::class,
'choice_label' => 'name',
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => UserCase::class,
]);
}
}

83
src/Form/UserFormType.php Normal file
View File

@ -0,0 +1,83 @@
<?php
namespace App\Form;
use App\Entity\User;
use App\Enums\CaseLevel;
use App\Enums\JobType;
use App\Enums\RateType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\EnumType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
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\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
class UserFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name', TextType::class, [
'label' => 'Name',
'attr' => [
'placeholder' => 'Name',
],
])
->add('username', TextType::class, [
'label' => 'Username',
'attr' => [
'placeholder' => 'Username',
],
])
->add('email', EmailType::class, [
'label' => 'Email',
'attr' => [
'placeholder' => 'Email',
],
])
->add('password', PasswordType::class, [
// instead of being set onto the object directly,
// this is read and encoded in the controller
'mapped' => false,
'attr' => ['autocomplete' => 'new-password'],
'constraints' => [
new NotBlank([
'message' => 'Please enter a password',
]),
new Length([
'min' => 6,
'minMessage' => 'Your password should be at least {{ limit }} characters',
// max length allowed by Symfony for security reasons
'max' => 4096,
]),
],
])
->add('caseWorker', CheckboxType::class)
->add('caseManager', CheckboxType::class)
->add('therapist', CheckboxType::class)
->add('su', CheckboxType::class, [
'label' => 'Admin',
])
->add('level', EnumType::class, [
'class' => CaseLevel::class,
])
->add('rateType', EnumType::class, [
'class' => RateType::class,
])
->add('rate', NumberType::class)
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => User::class,
]);
}
}