🎈 Welcome to the Marketplace — Explore and discover the ecosystem around DatoCMS, and share your own work with the community!

Force Block Field plugin

Force modula fields to apply blocks set in validation.

This is a Community Plugin! Learn how create your own plugin, or copy and remix existing ones in our documentation

Force Block Field Plugin

Modula fields let you choose the Blocks you'd like user to be able to apply to you field, by setting blocks in the Validations View.

However, when a user creates a new instance of the model, it still requires the user to manually add the block, even when it's set to required.

This plugin lets you automatically insert the blocks defined in the validators section of the fields edit properties dialog.

Add the Addon and then Select the blocks (matching the ones you've set in the validator) you want to automatically attach when a new instance of the model is generated.

DataCMS SDK version

This plugin uses ctx.pendingField which was introduced around this version.

"datocms-plugin-sdk": "^0.3.20",
"datocms-react-ui": "^0.3.21",

#Example Add the validators you want this field to support

Goto the Presentation Tab and add the Force Blocks plugin. Then select the validators you want to automatically add to new instances of the model.

When you create a new model or edit an existing one, the plugin will check the field to see if each validation should be applied and apply it, if it isn't already applied.

As you can see, it also works with fields that require 1 or more blocks. If you try to remove the block, it will automatically add it back in. All error checking for the block should also continue to work.

##Issues

lists all blocks used by model in Presentation View.

The introduction of the ctc.pendingField property in SDK v2 meant I could detect the field your were editing, and list only that fields validators, whereas before I had to display all validators for the model.

Localisation

I think there is some jiggery pokery that needs to be done for localisation support, but for lack of documentation, I haven't a clue what that is. Something to do with field_ids, and fields paths or something.

Reference

DatoCMS helped fix errors and introduce new features into the SDK which helped make this plugin possible. So big thanks to them for being so on it.

Links I read to help make this plugin

The main reference.

PUblish to market place

- https://www.datocms.com/docs/plugin-sdk/publishing-to-marketplace

Force Block Field plugin
Force modula fields to apply blocks set in validation.
Publisher
Author gravataremile.swain
Package
Visit NPM
Current version
0.1.5
Installs count
Last update