Download the PHP package schantldev/statamic-formattach without Composer
On this page you can find all versions of the php package schantldev/statamic-formattach. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package statamic-formattach
Statamic FormAttach
Statamic FormAttach is a Statamic addon that allows to easily attach any files to form submission mails dynamically.
Features
This addon provides:
- A standard PDF attachment for form submissions[^1]
- Support for any other attachment(s) you might need to add dynamically
How to Install
Install the addon using composer.
Publish the configuration file.
Swap out the send email job in your statamic/forms.php
config file.
How to Use
After publishing the config file, you will be able to add attachments to any forms you wish. There's an array with the form handle and attachments to possibly be added.
Attaching PDFs
There is a default attachment that will generate a PDF using Spatie's Browsershot package[^1]. In the config, you can find more settings for choosing a paper size and setting a custom logo. If that's not enough, you can opt in to publish the view[^3] and adjust it to your needs or create your own custom attachment.
[!TIP] If you wanna see a live preview while working on the view, there's a way! There are two routes you can use for your already saved submission:
- as HTML: submissions/{submission_id}/preview
- as PDF: submissions/{submission_id}/preview_pdf
Custom attachments
Sometimes, PDFs are just not enough or you need some more fine-grained control over the attachment. In that case, you can extend the FormAttachment
class and implement its abstract method to provide any attachment in form of a mailable attachment[^2].
Controlling whether to add an attachment
In the above excerpt, you can see a check()
method that is present within a FormAttachment class. Use it to decide on whether to add an attachment or not. You can use the SubmissionHelper object that gives you access to the submission data, the form, the blueprint of the form and the config of the mail.
Example: (only attach PDF to owner mail - in a Statamic Peak context)
Contributing and Issues
Contributions and discussions are always welcome, no matter how large or small. If you happen to find an issue, please open up a Github issue or do a PR if you can.
[^1]: The addon required Browserhot for the PDF attachment to work out of the box. Please note that the addon will not install Browsershot for you as you might have already installed some version of it. Please install Browsershot directly into your project. [^2]: Refer to the offical Laravel documentation on how to create attachments in various ways.