Package: collective.volto.formsupport
collective.volto.formsupportAdd some helper routes and functionalities for Volto sites withformblocks provided byvolto-form-blockVolto plugin.plone.restapi endpoints@submit-formEndpoint that the frontend should call as a submit action.You can call it with a POST on the context where the block form is stored like this:> curl -i -X POST http://localhost:8080/Plone/my-form/@submit-form -H 'Accept: application/json' -H 'Content-Type: application/json' --data-raw '{"block_id": "123456789", "data": [{"field_id": "foo", "value":"foo", "label": "Foo"},{"field_id": "from", "value": "support@foo.com"}, {"field_id":"name", "value": "John Doe", "label": "Name"}]}'where:my-formis the context where we have a form blockblock_idis the id of the blockdatacontains the submitted form dataCalling this endpoint, it will do some actions (based on block settings) and returns a204response.@form-dataThis is an expansion component.There is a rule that returns aform-dataitem into “components” slot if the user can edit the
context (Modify portal contentpermission) and there is a block that can store data.Calling with “expand=true”, this endpoint returns the stored data:> curl -i -X GET http://localhost:8080/Plone/my-form/@form-data -H 'Accept: application/json' -H 'Content-Type: application/json' --user admin:adminAnd replies with something similar:{
    "@id": "http://localhost:8080/Plone/my-form/@form-data",
    "items": [
        {
        "block_id": "123456789",
        "date": "2021-03-10T12:25:24",
        "from": "support@foo.com",
        "id": 912078826,
        "name": "John Doe"
        },
        ...
    ],
    "items_total": 42
}@form-data-exportReturns a csv file with all data (only for users that haveModify portal contentpermission):> curl -i -X GET http://localhost:8080/Plone/my-form/@form-data-export -H 'Accept: application/json' -H 'Content-Type: application/json' --user admin:adminIf form fields changed between some submissions, you will see also columns related to old fields.@form-data-clearReset the store (only for users that haveModify portal contentpermission):> curl -i -X GET http://localhost:8080/Plone/my-form/@form-data-clear -H 'Accept: application/json' -H 'Content-Type: application/json' --user admin:adminForm actionsUsingvolto-form-blockyou can set if the form submit should send data to an email address
or store it into an internal catalog (or both).SendIf block is set to send data, an email with form data will be sent to the recipient set in block settings or (if not set) to the site address.If ther is anattachmentsfield in the POST data, these files will be attached to the emal sent.StoreIf block is set to store data, we store it into the content that has that block (with asouper.plonecatalog).The store is an adapter registered forIFormDataStoreinterface, so you can override it easily.Only fields that are also in block settings are stored. Missing ones will be skipped.Each Record stores also twoserviceattributes:fields_labels: a mapping of field ids to field labels. This is useful when we export csv files, so we can labels for the columns.fields_order: sorted list of field ids. This can be used in csv export to keep the order of fields.We store these attributes because the form can change over time and we want to have a snapshot of the fields in the Record.Block serializerThere is a custom block serializer for typeform.This serializer removes all fields that start with “**default_**" if the user can’t edit the current context.This is useful because we don’t want to expose some internals configurations (for example the recipient email address)
to external users that should only fill the form.If the block has a fieldcaptcha, an additional propertycaptcha_propsis serialized by theserializemethod provided by the ICaptchaSupport named adapter, the result contains useful metadata for the client, as the
captcha public_key, ie:{
    "subblocks": [
        ...
    ],
    "captcha": "recaptcha",
    "captcha_props": {
        "provider": "recaptcha",
        "public_key": "aaaaaaaaaaaaa"
    }
}Captcha supportCaptcha support requires a specific name adapter that implementsICaptchaSupport.
This product contains implementations for:HCaptcha (plone.formwidget.hcaptcha)Google ReCaptcha (plone.formwidget.recaptcha)Custom questions and answers (collective.z3cform.norobots)Honeypot (collective.honeypot)Each implementation must be included, installed and configured separately.To include one implementation, you need to install the egg with the needed extras_require:collective.volto.formsupport[recaptcha]collective.volto.formsupport[hcaptcha]collective.volto.formsupport[norobots]collective.volto.formsupport[honeypot]During the form post, the token captcha will be verified with the defined captcha method.For captcha supportvolto-form-blockversion >= 2.4.0 is required.Honeypot configurationIf honeypot dependency is available in the buildout, the honeypot validation is enabled and selectable in forms.Default field name isprotected_1and you can change it with an environment variable. Seecollective.honeypotfor details.Attachments upload limitsForms can have one or more attachment field to allow users to upload some files.These files will be sent via mail, so it could be a good idea setting a limit to them.
For example if you use Gmail as mail server, you can’t send messages with attachments > 25MB.There is an environment variable that you can use to set that limit (in MB):[instance]
environment-vars =
    FORM_ATTACHMENTS_LIMIT 25By default this is not set.The upload limit is also passed to the frontend in the form data with theattachments_limitkey.Content-transfer-encodingIt is possible to set the content-transfer-encoding for the email body, settings the environment
variableMAIL_CONTENT_TRANSFER_ENCODING:[instance]
environment-vars =
    MAIL_CONTENT_TRANSFER_ENCODING base64This is useful for some SMTP servers that have problems withquoted-printableencoding.By default the content-transfer-encoding isquoted-printableas overrided inhttps://github.com/zopefoundation/Products.MailHost/blob/master/src/Products/MailHost/MailHost.py#L65ExamplesThis add-on can be seen in action at the following sites:https://www.comune.modena.it/form/contattiTranslationsThis product has been translated intoItalianInstallationInstall collective.volto.formsupport by adding it to your buildout:[buildout]

...

eggs =
    collective.volto.formsupportand then runningbin/buildoutContributeIssue Tracker:https://github.com/collective/collective.volto.formsupport/issuesSource Code:https://github.com/collective/collective.volto.formsupportLicenseThe project is licensed under the GPLv2.AuthorsThis product was developed byRedTurtle Technologyteam.ContributorsRedTurtle Technology,sviluppo@redturtle.itMauro Amico,mauro.amico@gmail.comChangelog2.7.0 (2023-04-03)Override content-transfer-encoding usingMAIL_CONTENT_TRANSFER_ENCODINGenv
[mamico]The form block can now be stored in a Volto block container (columns,
accordion, tabs, etc)
[tiberiuichim]2.6.2 (2022-11-07)Fix collective.honeypot version.
[cekk]2.6.1 (2022-11-07)Fix dependencies.
[cekk]2.6.0 (2022-11-07)Add collective.honeypot support.
[cekk]2.5.0 (2022-10-04)Add limit attachments validation. Can be configured with environment variable.
[cekk]Export also compiling date in csv.
[cekk]2.4.0 (2022-09-08)Add collective.z3cform.norobots support
[erral]2.3.0 (2022-05-26)Breaking change: changed the way to store data keys. Now we use field_id as key for Records.
[cekk]Fix quoting in csv export.
[cekk]Generate csv columns with proper field labels, and keep the form order.
[cekk]Captcha support #13.
[mamico]2.2.0 (2022-04-07)Notify an event on sumbit.
[mamico]2.1.0 (2022-03-25)Support for user_as_bcc field in volto-form-block: send a separate mail for each email field with that flag.
[cekk]2.0.3 (2021-10-25)Fix permission checks in serializer.
[nzambello]2.0.2 (2021-10-25)Fix permission checks.
[cekk]2.0.1 (2021-10-18)[fix] do not send attachments multiple times.
[cekk]2.0.0 (2021-08-19)Convert field types: checkbox => multiple_choice and radio => single_choice
to follow new schema in volto-form-block (https://github.com/collective/volto-form-block/pull/7).
[cekk]1.0.5 (2021-05-12)Added Brazilian Portuguese (pt_BR) translations.
[ericof]1.0.4 (2021-04-15)Changed the classifiers inside setup.py. This should fix some installation
issues.
[arsenico13]1.0.3 (2021-04-08)NEW: The @submit-form entry-point now takes into account if a field is “marked”
with “use_as_reply_to” and use that field for “from” and “reply to”.
[arsenico13]1.0.2 (2021-03-24)Fix form_data for anon.
[cekk]1.0.1 (2021-03-24)Fix README for pypi.
[cekk]1.0.0 (2021-03-24)Initial release.
[cekk]