From 3f3ecf007171e7f898654e4c9449f7f94a3503ac Mon Sep 17 00:00:00 2001 From: philipp lang Date: Tue, 18 Jun 2024 02:00:36 +0200 Subject: [PATCH] Add non nami members --- app/Form/Fields/NamiField.php | 2 +- tests/Feature/Form/FormRegisterActionTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/Form/Fields/NamiField.php b/app/Form/Fields/NamiField.php index 50b9db65..21f7c1cd 100644 --- a/app/Form/Fields/NamiField.php +++ b/app/Form/Fields/NamiField.php @@ -54,7 +54,7 @@ class NamiField extends Field } return [ - $this->key . '.*.id' => ['required', 'numeric', 'exists:members,mitgliedsnr'], + $this->key . '.*.id' => ['nullable', 'numeric', 'exists:members,mitgliedsnr'], ...$rules, ]; } diff --git a/tests/Feature/Form/FormRegisterActionTest.php b/tests/Feature/Form/FormRegisterActionTest.php index fdd5ebee..d581d98d 100644 --- a/tests/Feature/Form/FormRegisterActionTest.php +++ b/tests/Feature/Form/FormRegisterActionTest.php @@ -556,6 +556,21 @@ class FormRegisterActionTest extends FormTestCase $this->assertEquals('othervalue', $form->participants->get(1)->data['other']); } + public function testItAddsMemberForNonNami(): void + { + $this->login()->loginNami(); + $this->createMember(['mitgliedsnr' => '5505']); + $form = Form::factory()->fields([ + $this->namiField('members'), + $this->textField('other')->required(false), + ]) + ->create(); + + $this->register($form, ['other' => '::string::', 'members' => [['id' => null, 'other' => 'othervalue']]]) + ->assertOk(); + $this->assertEquals('othervalue', $form->participants->get(1)->data['other']); + } + public function testItValidatesMembersFields(): void { $this->login()->loginNami();