Hello there,
I am trying to send an email with multiple attachments after a form submission. The files already exist and are not uploaded in the form. In the controller, I am trying to get the files uploaded in the block field in the backend and an additional based on the selected a value in a form input. That is a part of the code in my controller:
$attachments = [];
foreach ($page->text()->blocks()->findBy('id', get('key'))->documents()->toFiles() as $file) :
$attachments[] = $file;
endforeach;
foreach ($page->text()->blocks()->findBy('id', get('key'))->trainings()->toStructure() as $training) :
if ($training->name() == get('training')) :
$attachments[] = $training->formular()->toFile();
endif;
endforeach;
After submission, I get the a typerror Kirby\Cms\App::file(): Argument #1 ($path) must be of type string, array given, called in /Users/sigi/projects/barbra-vite/kirby/config/methods.php on line 155
Does anyone see where my mistake could be? Any help is much appreciated!
Sigi