Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[145] Make min and max age of signup configurable #175

Merged
merged 1 commit into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config/instances/ds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ contribution:
description: Studenten en werklozen
- amount: null
description: "Werkenden: 0,5% van het netto inkomen (minimaal €15 per kwartaal)"
signup:
min_age: 16
max_age: null
3 changes: 3 additions & 0 deletions config/instances/rood.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ contribution:
description: €3500 bruto en daarboven
- amount: null
description: ik betaal een hogere contributie, namelijk:
signup:
min_age: 14
max_age: 27
2 changes: 2 additions & 0 deletions src/Controller/MemberController.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ public function apply(Request $request): Response {
$membershipApplication->setRegistrationTime(new \DateTime());
$membershipApplication->setContributionPeriod(Member::PERIOD_QUARTERLY);
$form = $this->createForm(MembershipApplicationType::class, $membershipApplication, [
'min_age' => $org_config['signup']['min_age'],
'max_age' => $org_config['signup']['max_age'],
'use_middle_name' => $this->getParameter('app.useMiddleName'),
'privacy_policy_url' => $this->getParameter('app.privacyPolicyUrl'),
'organization_name' => $this->getParameter('app.organizationName'),
Expand Down
2 changes: 2 additions & 0 deletions src/DataFixtures/MemberFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function load(ObjectManager $manager)
$divisionNooderhaaks = new Division();
$divisionNooderhaaks->setName("Noorderhaaks");
$divisionNooderhaaks->setPostCode("1234AB");
$divisionNooderhaaks->setCanBeSelectedOnApplication(true);

$contactNooderhaaks = new Member();
$contactNooderhaaks->setId(1338);
Expand All @@ -45,6 +46,7 @@ public function load(ObjectManager $manager)
$divisionAchterhoek = new Division();
$divisionAchterhoek->setName("Achterhoek");
$divisionAchterhoek->setPostCode("4321BA");
$divisionAchterhoek->setCanBeSelectedOnApplication(true);

$contactAchterhoek = new Member();
$contactAchterhoek->setId(8673);
Expand Down
31 changes: 28 additions & 3 deletions src/Form/MembershipApplicationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,31 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder
->add('lastName', null, ['label' => 'Achternaam', 'error_bubbling' => true, 'constraints' => [new NotBlank()]])
->add('email', null, ['label' => 'E-mailadres', 'error_bubbling' => true, 'constraints' => [new NotBlank()]])
->add('phone', null, ['label' => 'Telefoonnummer', 'error_bubbling' => true, 'constraints' => [new NotBlank()]])
->add('phone', null, ['label' => 'Telefoonnummer', 'error_bubbling' => true, 'constraints' => [new NotBlank()]]);

if ($options['max_age']) {
$age_constraint = new Age([
'min' => $options['min_age'],
'max' => $options['max_age'],
'message' => 'Je moet tussen de {{ min }} en {{ max }} jaar oud zijn om lid te worden van ' . $options['organization_name'] . '.'
]);
} else {
$age_constraint = new Age([
'min' => $options['min_age'],
'message' => 'Je moet minimaal {{ min }} jaar oud zijn om lid te worden van ' . $options['organization_name'] . '.'
]);
}

$builder
->add('dateOfBirth', null, [
'label' => 'Geboortedatum',
'required' => true,
'widget' => 'single_text',
'constraints' => [new NotBlank(), new Age(['min' => 14, 'max' => 27, 'message' => 'Je moet tussen de {{ min }} en {{ max }} jaar oud zijn om lid te worden van ROOD.'])],
'constraints' => [new NotBlank(), $age_constraint],
'error_bubbling' => true
])
]);

$builder
// ->add('iban', null, ['label' => 'IBAN-rekeningnummer', 'error_bubbling' => true])
->add('address', null, ['label' => 'Adres', 'error_bubbling' => true, 'constraints' => [new NotBlank()]])
->add('city', null, ['label' => 'Plaats', 'error_bubbling' => true, 'constraints' => [new NotBlank()]])
Expand Down Expand Up @@ -83,5 +100,13 @@ public function configureOptions(OptionsResolver $resolver)
$resolver->setRequired([
'contribution'
]);

$resolver->setRequired([
'min_age'
]);

$resolver->setRequired([
'max_age'
]);
}
}
Loading