diff --git a/app/Form/Data/FieldCollection.php b/app/Form/Data/FieldCollection.php index 5ec04a75..3c6c6d7b 100644 --- a/app/Form/Data/FieldCollection.php +++ b/app/Form/Data/FieldCollection.php @@ -62,7 +62,10 @@ class FieldCollection extends Collection */ public static function fromRequest(Form $form, array $input): self { - return $form->getFields()->each(fn ($field) => $field->value = array_key_exists($field->key, $input) ? $input[$field->key] : $field->default()); + return $form->getFields()->map(function ($field) use ($input) { + $field->value = array_key_exists($field->key, $input) ? $input[$field->key] : $field->default(); + return $field; + }); } public function find(Field $givenField): ?Field diff --git a/app/Form/Fields/CheckboxField.php b/app/Form/Fields/CheckboxField.php index 35ada00e..511c039a 100644 --- a/app/Form/Fields/CheckboxField.php +++ b/app/Form/Fields/CheckboxField.php @@ -4,6 +4,8 @@ namespace App\Form\Fields; use App\Form\Models\Form; use App\Form\Models\Participant; +use App\Form\Presenters\BooleanPresenter; +use App\Form\Presenters\Presenter; use Faker\Generator; use Illuminate\Validation\Rule; @@ -72,4 +74,9 @@ class CheckboxField extends Field public function afterRegistration(Form $form, Participant $participant, array $input): void { } + + public function getPresenter(): Presenter + { + return app(BooleanPresenter::class); + } } diff --git a/app/Form/Presenters/BooleanPresenter.php b/app/Form/Presenters/BooleanPresenter.php new file mode 100644 index 00000000..24541b43 --- /dev/null +++ b/app/Form/Presenters/BooleanPresenter.php @@ -0,0 +1,15 @@ +