Compare commits
2 Commits
93d4511ee8
...
56e0223492
Author | SHA1 | Date |
---|---|---|
|
56e0223492 | |
|
5e49e5bd59 |
|
@ -17,6 +17,6 @@ class EmailField extends TextField
|
||||||
*/
|
*/
|
||||||
public function getRegistrationRules(Form $form): array
|
public function getRegistrationRules(Form $form): array
|
||||||
{
|
{
|
||||||
return [$this->key => $this->required ? ['required', 'string', 'email'] : ['nullable', 'string']];
|
return [$this->key => $this->required ? ['required', 'string', 'email'] : ['nullable', 'email', 'string']];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,6 +254,18 @@ class FormRegisterActionTest extends FormTestCase
|
||||||
['vorname' => 5],
|
['vorname' => 5],
|
||||||
['vorname' => 'Vorname der Mutter muss ein String sein.']
|
['vorname' => 'Vorname der Mutter muss ein String sein.']
|
||||||
];
|
];
|
||||||
|
|
||||||
|
yield [
|
||||||
|
$this->emailField('email')->name('Mail')->required(true),
|
||||||
|
['email' => 'alaaa'],
|
||||||
|
['email' => 'Mail muss eine gültige E-Mail-Adresse sein.']
|
||||||
|
];
|
||||||
|
|
||||||
|
yield [
|
||||||
|
$this->emailField('email')->name('Mail')->required(false),
|
||||||
|
['email' => 'alaaa'],
|
||||||
|
['email' => 'Mail muss eine gültige E-Mail-Adresse sein.']
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItValidatesGroupFieldWithParentGroupField(): void
|
public function testItValidatesGroupFieldWithParentGroupField(): void
|
||||||
|
|
|
@ -42,14 +42,16 @@ class FormRegisterMailTest extends FormTestCase
|
||||||
FormtemplateSectionRequest::new()->name('Persönliches')->fields([
|
FormtemplateSectionRequest::new()->name('Persönliches')->fields([
|
||||||
$this->textField('vorname')->name('Vorname')->specialType(SpecialType::FIRSTNAME),
|
$this->textField('vorname')->name('Vorname')->specialType(SpecialType::FIRSTNAME),
|
||||||
$this->textField('nachname')->specialType(SpecialType::LASTNAME),
|
$this->textField('nachname')->specialType(SpecialType::LASTNAME),
|
||||||
|
$this->checkboxField('fullyear')->name('Volljährig'),
|
||||||
])
|
])
|
||||||
]))
|
]))
|
||||||
->data(['vorname' => 'Max', 'nachname' => 'Muster'])
|
->data(['vorname' => 'Max', 'nachname' => 'Muster', 'fullyear' => true])
|
||||||
->create();
|
->create();
|
||||||
|
|
||||||
$mail = new ConfirmRegistrationMail($participant);
|
$mail = new ConfirmRegistrationMail($participant);
|
||||||
$mail->assertSeeInText('# Hallo Max Muster');
|
$mail->assertSeeInText('# Hallo Max Muster');
|
||||||
$mail->assertSeeInText('## Persönliches');
|
$mail->assertSeeInText('## Persönliches');
|
||||||
$mail->assertSeeInText('* Vorname: Max');
|
$mail->assertSeeInText('* Vorname: Max');
|
||||||
|
$mail->assertSeeInText('* Volljährig: Ja');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ use App\Form\Fields\CheckboxesField;
|
||||||
use App\Form\Fields\CheckboxField;
|
use App\Form\Fields\CheckboxField;
|
||||||
use App\Form\Fields\DateField;
|
use App\Form\Fields\DateField;
|
||||||
use App\Form\Fields\DropdownField;
|
use App\Form\Fields\DropdownField;
|
||||||
|
use App\Form\Fields\EmailField;
|
||||||
use App\Form\Fields\GroupField;
|
use App\Form\Fields\GroupField;
|
||||||
use App\Form\Fields\NamiField;
|
use App\Form\Fields\NamiField;
|
||||||
use App\Form\Fields\RadioField;
|
use App\Form\Fields\RadioField;
|
||||||
|
@ -26,6 +27,11 @@ trait CreatesFormFields
|
||||||
return FormtemplateFieldRequest::type(TextField::class)->key($key ?? $this->randomKey());
|
return FormtemplateFieldRequest::type(TextField::class)->key($key ?? $this->randomKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function emailField(?string $key = null): FormtemplateFieldRequest
|
||||||
|
{
|
||||||
|
return FormtemplateFieldRequest::type(EmailField::class)->key($key ?? $this->randomKey());
|
||||||
|
}
|
||||||
|
|
||||||
protected function checkboxesField(?string $key = null): FormtemplateFieldRequest
|
protected function checkboxesField(?string $key = null): FormtemplateFieldRequest
|
||||||
{
|
{
|
||||||
return FormtemplateFieldRequest::type(CheckboxesField::class)->key($key ?? $this->randomKey());
|
return FormtemplateFieldRequest::type(CheckboxesField::class)->key($key ?? $this->randomKey());
|
||||||
|
@ -63,6 +69,6 @@ trait CreatesFormFields
|
||||||
|
|
||||||
protected function randomKey(): string
|
protected function randomKey(): string
|
||||||
{
|
{
|
||||||
return preg_replace('/[\-0-9]/', '', str()->uuid().str()->uuid());
|
return preg_replace('/[\-0-9]/', '', str()->uuid() . str()->uuid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue