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();