Fixed: Dont sync member when member is manual
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details

This commit is contained in:
philipp lang 2024-06-19 13:05:45 +02:00
parent 03c19aa5fb
commit 668cf9d292
2 changed files with 5 additions and 2 deletions

View File

@ -107,7 +107,7 @@ class NamiField extends Field
public function afterRegistration(Form $form, Participant $participant, array $input): void
{
foreach ($input[$this->key] as $memberData) {
$member = Member::firstWhere(['mitgliedsnr' => $memberData['id']]);
$member = $memberData['id'] ? Member::firstWhere(['mitgliedsnr' => $memberData['id']]) : null;
$data = [];
foreach (FieldCollection::fromRequest($form, $memberData) as $field) {
$data[$field->key] = $field->namiType === null || $member === null

View File

@ -575,17 +575,20 @@ class FormRegisterActionTest extends FormTestCase
public function testItAddsMemberForNonNami(): void
{
$this->login()->loginNami();
$this->createMember(['mitgliedsnr' => null]);
$form = Form::factory()->fields([
$this->namiField('members'),
$this->textField('gender')->namiType(NamiType::GENDER)->required(false),
$this->textField('vorname')->namiType(NamiType::FIRSTNAME)->required(false),
$this->textField('other')->required(false),
])
->create();
$this->register($form, ['other' => '::string::', 'members' => [['id' => null, 'gender' => 'Herr', 'other' => 'othervalue']]])
$this->register($form, ['other' => '::string::', 'vorname' => 'LA', 'members' => [['id' => null, 'vorname' => 'BBB', 'gender' => 'Herr', 'other' => 'othervalue']]])
->assertOk();
$this->assertEquals('othervalue', $form->participants->get(1)->data['other']);
$this->assertEquals('Herr', $form->participants->get(1)->data['gender']);
$this->assertEquals('BBB', $form->participants->get(1)->data['vorname']);
}
public function testItValidatesNamiTypeFieldsForNonMembers(): void