1

I have created a custom Drupal 8 module which defines a custom field type and the corresponding formatter and widget for that.

This field should be added by the admin to whichever Content Type he wants. The module's code, on specific occasions, will detect if this field type exists on a node and do some extra actions if it does.

Although the admin is responsible to add this custom field type to any CTs he likes, i would like to preset, with code, the internal settings of this field (e.g. make Allowed number of values = unlimited by default) and preferably lock the settings of the field altogether.

Scenario would be that admin adds the field to the desired CT and is allowed to make no changes to the field settings. This way the field will be securely configured, by the module itself, and the module's code would work as expected at all times without fear or extra checks that specific settings are not changed by the admin.

Is that possible and if yes how could it be implemented?

2
  • 1
    can't you just set defaults in defaultStorageSettings and just not provide any editing in storageSettingsForm? haven't tried that, but seems like that would allow setting in code and no edits. I think there's a setting for cardinality you can set as default (not sure).
    – troseman
    Commented Jun 7, 2018 at 19:43
  • Im not sure if you mean the following drupal.org/node/2869873, but this did the trick for me. Thank you for the pointer, as this was the one that led me to the previous link which solved my problem. Although my initial intention was to lock down the field for editing altogether, this still does the trick for me. Commented Jun 9, 2018 at 20:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.