Skip to content

Commit

Permalink
Merge pull request #175 from roodjong/145-configurable-max-age
Browse files Browse the repository at this point in the history
[145] Make min and max age of signup configurable
  • Loading branch information
pingiun authored May 19, 2024
2 parents 66c8c1d + 71f7a6d commit 4ea83f8
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
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'
]);
}
}

0 comments on commit 4ea83f8

Please sign in to comment.