Please how can I alter the default field settings whenever a new field is added?
NB I am not asking how to set the default whenever a new entity is added. This is about changing the pre-populated values on the page "Administration->Structure->Content types->XXX->Manage fields->Add field when a field is added"
NB This question is for D8. In D7 the answer is to use hook_field_info_alter.
Specifically I am using the module allowed_formats, and I would like every new text_with_summary or text_long field to have defaults of:
- Allowed formats = "Basic HTML" only
- Form display settings "Hide the help link About text formats." and "Hide text format guidelines." enabled.
The defaults need to work even if the new field is created in code. In particular it's important to work for the Body field that is created automatically on a new content type.
I'm struggling because looking at the code, the defaults come from the public static function TextWithSummaryItem::defaultFieldSettings and there doesn't seem to be any hook.
hook_field_config_presave()
to change the settings before they are saved. Orhook_entity_form_display_presave()
for the settings in the form mode.