Lint Registration
This commit is contained in:
parent
34fb96dabe
commit
9d7d039530
|
@ -77,13 +77,15 @@ class NamiField extends Field
|
|||
foreach ($c as $field) {
|
||||
foreach ($field->getRegistrationRules() as $ruleKey => $rule) {
|
||||
foreach ($inputMembers as $memberIndex => $inputMember) {
|
||||
if (str($ruleKey)->contains('*')) {
|
||||
foreach (request($this->key . '.' . $memberIndex . '.' . $field->key) as $i => $k) {
|
||||
$rules[$this->key . '.' . $memberIndex . '.' . str($ruleKey)->replace('*', $i)] = $field->name . ' für Mitglied Nr ' . $inputMember['id'];
|
||||
}
|
||||
} else {
|
||||
$rules[$this->key . '.' . $memberIndex . '.' . $ruleKey] = $field->name . ' für Mitglied Nr ' . $inputMember['id'];
|
||||
}
|
||||
$message = $field->name . ' für ein Mitglied';
|
||||
$rules = array_merge(
|
||||
$rules,
|
||||
str($ruleKey)->contains('*')
|
||||
? collect(request($this->key . '.' . $memberIndex . '.' . $field->key))
|
||||
->mapWithKeys(fn ($value, $key) => [$this->key . '.' . $memberIndex . '.' . str($ruleKey)->replace('*', $key) => $message])
|
||||
->toArray()
|
||||
: [$this->key . '.' . $memberIndex . '.' . $ruleKey => $message]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -330,8 +330,8 @@ class FormRegisterActionTest extends FormTestCase
|
|||
->create();
|
||||
|
||||
$this->register($form, ['other' => 'ooo', 'members' => [['id' => '5505', 'other' => ''], ['id' => '5506', 'other' => '']]])
|
||||
->assertJsonValidationErrors(['members.0.other' => 'Andere für Mitglied Nr 5505 ist erforderlich.'])
|
||||
->assertJsonValidationErrors(['members.1.other' => 'Andere für Mitglied Nr 5506 ist erforderlich.']);
|
||||
->assertJsonValidationErrors(['members.0.other' => 'Andere für ein Mitglied ist erforderlich.'])
|
||||
->assertJsonValidationErrors(['members.1.other' => 'Andere für ein Mitglied ist erforderlich.']);
|
||||
}
|
||||
|
||||
public function testItValidatesIfMemberExists(): void
|
||||
|
@ -362,7 +362,24 @@ class FormRegisterActionTest extends FormTestCase
|
|||
$this->register($form, ['other' => [], 'members' => [
|
||||
['id' => '5505', 'other' => ['A', 'missing']]
|
||||
]])
|
||||
->assertJsonValidationErrors(['members.0.other.1' => 'Der gewählte Wert für Andere für Mitglied Nr 5505 ist ungültig.']);
|
||||
->assertJsonValidationErrors(['members.0.other.1' => 'Der gewählte Wert für Andere für ein Mitglied ist ungültig.']);
|
||||
}
|
||||
|
||||
public function testItValidatesMembersCheckboxesAsArray(): void
|
||||
{
|
||||
$this->login()->loginNami();
|
||||
$this->createMember(['mitgliedsnr' => '5505']);
|
||||
$form = Form::factory()
|
||||
->sections([FormtemplateSectionRequest::new()->fields([
|
||||
$this->namiField('members'),
|
||||
$this->checkboxesField('other')->name('Andere')->options(['A', 'B']),
|
||||
])])
|
||||
->create();
|
||||
|
||||
$this->register($form, ['other' => [], 'members' => [
|
||||
['id' => '5505', 'other' => 'lala']
|
||||
]])
|
||||
->assertJsonValidationErrors(['members.0.other' => 'Andere für ein Mitglied muss ein Array sein.']);
|
||||
}
|
||||
|
||||
public function testItSetsDefaultValueForFieldsThatAreNotNamiFillable(): void
|
||||
|
|
Loading…
Reference in New Issue