Validate fields for manual member
This commit is contained in:
parent
40407214e3
commit
03c19aa5fb
|
@ -42,12 +42,13 @@ class NamiField extends Field
|
|||
public function getRegistrationRules(Form $form): array
|
||||
{
|
||||
$rules = [$this->key => 'present|array'];
|
||||
$inputMembers = request($this->key);
|
||||
|
||||
foreach ($form->getFields()->forMembers()->noNamiField() as $field) {
|
||||
$r = $field->getRegistrationRules($form);
|
||||
|
||||
foreach ($r as $ruleKey => $rule) {
|
||||
$rules[$this->key . '.*.' . $ruleKey] = $field->namiType === null ? $rule : '';
|
||||
foreach ($form->getFields()->noNamiField()->forMembers() as $field) {
|
||||
foreach ($field->getRegistrationRules($form) as $ruleKey => $rule) {
|
||||
foreach ($inputMembers as $memberIndex => $inputMember) {
|
||||
$rules[$this->key . '.' . $memberIndex . '.' . $ruleKey] = !$inputMember['id'] || $field->namiType === null ? $rule : '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,12 +70,9 @@ class NamiField extends Field
|
|||
return [];
|
||||
}
|
||||
|
||||
$c = $form->getFields()->noNamiField()->forMembers();
|
||||
|
||||
foreach ($c as $field) {
|
||||
foreach ($form->getFields()->noNamiField()->forMembers() as $field) {
|
||||
foreach ($field->getRegistrationRules($form) as $ruleKey => $rule) {
|
||||
foreach ($inputMembers as $memberIndex => $inputMember) {
|
||||
|
||||
$message = $field->name . ' für ein Mitglied';
|
||||
$rules = array_merge(
|
||||
$rules,
|
||||
|
|
|
@ -575,7 +575,6 @@ class FormRegisterActionTest extends FormTestCase
|
|||
public function testItAddsMemberForNonNami(): void
|
||||
{
|
||||
$this->login()->loginNami();
|
||||
$this->createMember(['mitgliedsnr' => '5505']);
|
||||
$form = Form::factory()->fields([
|
||||
$this->namiField('members'),
|
||||
$this->textField('gender')->namiType(NamiType::GENDER)->required(false),
|
||||
|
@ -589,6 +588,19 @@ class FormRegisterActionTest extends FormTestCase
|
|||
$this->assertEquals('Herr', $form->participants->get(1)->data['gender']);
|
||||
}
|
||||
|
||||
public function testItValidatesNamiTypeFieldsForNonMembers(): void
|
||||
{
|
||||
$this->login()->loginNami();
|
||||
$form = Form::factory()->fields([
|
||||
$this->namiField('members'),
|
||||
$this->textField('gender')->name('Geschlecht')->namiType(NamiType::GENDER)->required(true),
|
||||
])
|
||||
->create();
|
||||
|
||||
$this->register($form, ['gender' => 'Herr', 'members' => [['id' => null, 'gender' => null]]])
|
||||
->assertJsonValidationErrors(['members.0.gender' => 'Geschlecht für ein Mitglied ist erforderlich.']);
|
||||
}
|
||||
|
||||
public function testItValidatesMembersFields(): void
|
||||
{
|
||||
$this->login()->loginNami();
|
||||
|
|
Loading…
Reference in New Issue