npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

volto-form-block

v3.8.2

Published

Volto block to build a form

Downloads

2,935

Readme

volto-form-block

Volto addon which adds a customizable form using a block. Intended to be used with collective.volto.formsupport.

Install with mrs-developer (see Volto docs) or with:

yarn add volto-form-block volto-subblocks

Note: Since version v2.0.0 of this addon, it's required collective.volto.formsupport 2.0.0 or higher (and its upgrade steps).

Note: Since version v2.1.2 of this addon, it's required Volto 14.2.0

Note: Since version v3.0.0 of this addon, it's required Volto >= 16.0.0-alpha.38

Features

This addon will add in your project the Form block and the needed reducers.

Form block view

Using the engine of subblocks, you can manage form fields adding, sorting and deleting items.

For each field, you can select the field type from:

  • Text
  • Textarea
  • Select
  • Single choice (radio buttons)
  • Multiple choice (checkbox buttons)
  • Checkbox
  • Date picker
  • File upload with DnD
  • E-mail
  • Static rich text (not a fillable field, just text to display between other fields)

For every field you can set a label and a help text. For select, radio and checkbox fields, you can select a list of values.

Captcha verification

This form addon is configured to work with HCaptcha, ReCaptcha and NoRobot to prevent spam.

In order to make one of these integrations work, you need to add https://github.com/plone/plone.formwidget.hcaptcha and/or https://github.com/plone/plone.formwidget.recaptcha and/or https://github.com/collective/collective.z3cform.norobots Plone addon and configure public and private keys in controlpanels.

HCaptcha

With HCaptcha integration, you also have an additional option in the sidebar in 'Captcha provider' to enable or disable the invisible captcha (see implications here).

In some test scenarios it's found that the "Passing Threshold" of HCaptcha must be configured as "Auto" to get the best results. In some test cases if one sets the Threshold to "Moderate" HCaptcha starts to fail.

OTP email validation

To prevent sending spam emails to users via the email address configured as sender, the 'email' fields type flagged as BCC will require the user to enter an OTP code received at the address entered in the field when user fills out the form.

Export

With backend support, you can store data submitted from the form. In Edit, you can export and clear stored data from the sidebar.

Additional fields

In addition to the fields described above, you can add any field you want. If you need a field that is not supported, PRs are always welcome, but if you have to use a custom field tailored on your project needs, then you can add additional custom fields.

config.blocks.blocksConfig.form.additionalFields.push({
  id: 'field type id',
  label:
    intl.formatMessage(messages.customFieldLabel) ||
    'Label for field type select, translation obj or string',
  component: MyCustomWidget,
  isValid: (formData, name) => true,
});

The widget component should have the following firm:

({
  id,
  name,
  title,
  description,
  required,
  onChange,
  value,
  isDisabled,
  invalid,
}) => ReactElement;

You should also pass a function to validate your field's data. The isValid function accepts formData (the whole form data) and the name of the field, thus you can access to your fields' data as formData[name] but you also have access to other fields.

isValid has the firm:

(formData, name) => boolean;

Example custom field here.

Static fields

In backend integration, you can add in block data an object called static_fields and the form block will show those in form view as readonly and will aggregate those with user compiled data.

i.e.: aggregated data from user federated authentication:

Static fields

Schema validators

If you want to validate configuration field (for example, testing if 'From email' is an address of a specific domain), you could add your validation functions to block config:

config.blocks.blocksConfig.form = {
  ...config.blocks.blocksConfig.form,
  schemaValidators: {
    fieldname: yourValidationFN(data),
  },
};

yourValidationFN have to return:

  • null if field is valid
  • a string with the error message if field is invalid.

Upgrade guide

To upgrade to version 2.4.0 you need to:

Video demos

VERSIONS

With [email protected] you need to upgrade collective.volto.formsupport to version 2.4.0