Skip to main content
Added function docs
Source Link
norman.lol
  • 19.1k
  • 6
  • 75
  • 129

Thanks to @Berdir and @4k4 who helped me out several times - I just followed their ideas, tested and wrote up the answers.

This first hook alters the field settings. I've included a second example for image settings.

/** * Implements hook_ENTITY_TYPE_create() for 'field_config'. */ function XXX_field_config_createMYMODULE_field_config_create(FieldConfigInterface $field) { if ($field->isSyncing()) return; switch ($field->getType()) { case 'image': $field->setSettings(['file_directory' => 'images', 'max_resolution' => '1080x1080']); break; case 'text_with_summary': case 'text_long': $field->setThirdPartySetting('allowed_formats', 'basic_html', 'basic_html'); break; } } 

This second hook alters the form display settings. The array_diff_key command is used to determine which fields are new.

/** * Implements hook_ENTITY_TYPE_presave(). * * Override field form display defaults used when a field is added to a content type. */ function XXX_entity_form_display_presaveMYMODULE_entity_form_display_presave(EntityFormDisplay $display) { $fields = $display->getComponents(); $origFields = (isset($display->original)) ? $display->original->getComponents() : []; foreach (array_diff_key($fields, $origFields) as $newField => $settings) { switch ($settings['type']) { case 'text_textarea_with_summary': case 'text_textarea': $settings['third_party_settings']['allowed_formats'] = ['hide_help' => '1', 'hide_guidelines' => '1']; $display->setComponent($newField, $settings); break; } } } 

Thanks to @Berdir and @4k4 who helped me out several times - I just followed their ideas, tested and wrote up the answers.

This first hook alters the field settings. I've included a second example for image settings.

/** * Implements hook_ENTITY_TYPE_create() for 'field_config'. */ function XXX_field_config_create(FieldConfigInterface $field) { if ($field->isSyncing()) return; switch ($field->getType()) { case 'image': $field->setSettings(['file_directory' => 'images', 'max_resolution' => '1080x1080']); break; case 'text_with_summary': case 'text_long': $field->setThirdPartySetting('allowed_formats', 'basic_html', 'basic_html'); break; } } 

This second hook alters the form display settings. The array_diff_key command is used to determine which fields are new.

/** * Implements hook_ENTITY_TYPE_presave(). * * Override field form display defaults used when a field is added to a content type. */ function XXX_entity_form_display_presave(EntityFormDisplay $display) { $fields = $display->getComponents(); $origFields = (isset($display->original)) ? $display->original->getComponents() : []; foreach (array_diff_key($fields, $origFields) as $newField => $settings) { switch ($settings['type']) { case 'text_textarea_with_summary': case 'text_textarea': $settings['third_party_settings']['allowed_formats'] = ['hide_help' => '1', 'hide_guidelines' => '1']; $display->setComponent($newField, $settings); break; } } } 

Thanks to @Berdir and @4k4 who helped me out several times - I just followed their ideas, tested and wrote up the answers.

This first hook alters the field settings. I've included a second example for image settings.

/** * Implements hook_ENTITY_TYPE_create() for 'field_config'. */ function MYMODULE_field_config_create(FieldConfigInterface $field) { if ($field->isSyncing()) return; switch ($field->getType()) { case 'image': $field->setSettings(['file_directory' => 'images', 'max_resolution' => '1080x1080']); break; case 'text_with_summary': case 'text_long': $field->setThirdPartySetting('allowed_formats', 'basic_html', 'basic_html'); break; } } 

This second hook alters the form display settings. The array_diff_key command is used to determine which fields are new.

/** * Implements hook_ENTITY_TYPE_presave(). * * Override field form display defaults used when a field is added to a content type. */ function MYMODULE_entity_form_display_presave(EntityFormDisplay $display) { $fields = $display->getComponents(); $origFields = (isset($display->original)) ? $display->original->getComponents() : []; foreach (array_diff_key($fields, $origFields) as $newField => $settings) { switch ($settings['type']) { case 'text_textarea_with_summary': case 'text_textarea': $settings['third_party_settings']['allowed_formats'] = ['hide_help' => '1', 'hide_guidelines' => '1']; $display->setComponent($newField, $settings); break; } } } 

Thanks to @Berdir and @4k4 who helped me out several times - I just followed their ideas, tested and wrote up the answers.

This first hook alters the field settings. I've included a second example for image settings.

function XXX_field_config_create(FieldConfigInterface $field) { if ($field->isSyncing()) return; switch ($field->getType()) { case 'image': $field->setSettings(['file_directory' => 'images', 'max_resolution' => '1080x1080']); break; case 'text_with_summary': case 'text_long': $field->setThirdPartySetting('allowed_formats', 'basic_html', 'basic_html'); break; } } 
/** * Implements hook_ENTITY_TYPE_create() for 'field_config'. */ function XXX_field_config_create(FieldConfigInterface $field) { if ($field->isSyncing()) return; switch ($field->getType()) { case 'image': $field->setSettings(['file_directory' => 'images', 'max_resolution' => '1080x1080']); break; case 'text_with_summary': case 'text_long': $field->setThirdPartySetting('allowed_formats', 'basic_html', 'basic_html'); break; } } 

This second hook alters the form display settings. The array_diff_key command is used to determine which fields are new.

/** * Implements hook_ENTITY_TYPE_presave(). * * Override field form display defaults used when a field is added to a content type. */ function XXX_entity_form_display_presave(EntityFormDisplay $display) { $fields = $display->getComponents(); $origFields = (isset($display->original)) ? $display->original->getComponents() : []; foreach (array_diff_key($fields, $origFields) as $newField => $settings) { switch ($settings['type']) { case 'text_textarea_with_summary': case 'text_textarea': $settings['third_party_settings']['allowed_formats'] = ['hide_help' => '1', 'hide_guidelines' => '1']; $display->setComponent($newField, $settings); break; } } } 

Thanks to @Berdir and @4k4 who helped me out several times - I just followed their ideas, tested and wrote up the answers.

This first hook alters the field settings. I've included a second example for image settings.

function XXX_field_config_create(FieldConfigInterface $field) { if ($field->isSyncing()) return; switch ($field->getType()) { case 'image': $field->setSettings(['file_directory' => 'images', 'max_resolution' => '1080x1080']); break; case 'text_with_summary': case 'text_long': $field->setThirdPartySetting('allowed_formats', 'basic_html', 'basic_html'); break; } } 

This second hook alters the form display settings. The array_diff_key command is used to determine which fields are new.

/** * Implements hook_ENTITY_TYPE_presave(). * * Override field form display defaults used when a field is added to a content type. */ function XXX_entity_form_display_presave(EntityFormDisplay $display) { $fields = $display->getComponents(); $origFields = (isset($display->original)) ? $display->original->getComponents() : []; foreach (array_diff_key($fields, $origFields) as $newField => $settings) { switch ($settings['type']) { case 'text_textarea_with_summary': case 'text_textarea': $settings['third_party_settings']['allowed_formats'] = ['hide_help' => '1', 'hide_guidelines' => '1']; $display->setComponent($newField, $settings); break; } } } 

Thanks to @Berdir and @4k4 who helped me out several times - I just followed their ideas, tested and wrote up the answers.

This first hook alters the field settings. I've included a second example for image settings.

/** * Implements hook_ENTITY_TYPE_create() for 'field_config'. */ function XXX_field_config_create(FieldConfigInterface $field) { if ($field->isSyncing()) return; switch ($field->getType()) { case 'image': $field->setSettings(['file_directory' => 'images', 'max_resolution' => '1080x1080']); break; case 'text_with_summary': case 'text_long': $field->setThirdPartySetting('allowed_formats', 'basic_html', 'basic_html'); break; } } 

This second hook alters the form display settings. The array_diff_key command is used to determine which fields are new.

/** * Implements hook_ENTITY_TYPE_presave(). * * Override field form display defaults used when a field is added to a content type. */ function XXX_entity_form_display_presave(EntityFormDisplay $display) { $fields = $display->getComponents(); $origFields = (isset($display->original)) ? $display->original->getComponents() : []; foreach (array_diff_key($fields, $origFields) as $newField => $settings) { switch ($settings['type']) { case 'text_textarea_with_summary': case 'text_textarea': $settings['third_party_settings']['allowed_formats'] = ['hide_help' => '1', 'hide_guidelines' => '1']; $display->setComponent($newField, $settings); break; } } } 
added 35 characters in body
Source Link
AdamS
  • 817
  • 7
  • 17

Thanks to @Berdir and @4k4 who helped me out several times - I just followed their ideas, tested and wrote up the answers.

This first hook alters the field settings. I've included a second example for image settings.

function XXX_field_config_create(FieldConfigInterface $field) { if ($field->isSyncing()) return; switch ($field->getType()) { case 'image': $field->setSettings(['file_directory' => 'images', 'max_resolution' => '1080x1080']); break; case 'text_with_summary': case 'text_long': $field->setThirdPartySetting('allowed_formats', 'basic_html', 'basic_html'); break; } } 

This second hook alters the form display settings. The array_diff_key command is used to determine which fields are new.

/** * Implements hook_ENTITY_TYPE_presave(). * * Override field form display defaults used when a field is added to a content type. */ function XXX_entity_form_display_presave(EntityFormDisplay $display) { $fields = $display->getComponents(); $origFields = (isset($display->original)) ? $display->original->getComponents(); : []; foreach (array_diff_key($fields, $origFields) as $newField => $settings) { switch ($settings['type']) { case 'text_textarea_with_summary': case 'text_textarea': $settings['third_party_settings']['allowed_formats'] = ['hide_help' => '1', 'hide_guidelines' => '1']; $display->setComponent($newField, $settings); break; } } } 

Thanks to @Berdir and @4k4 who helped me out several times - I just followed their ideas, tested and wrote up the answers.

This first hook alters the field settings. I've included a second example for image settings.

function XXX_field_config_create(FieldConfigInterface $field) { if ($field->isSyncing()) return; switch ($field->getType()) { case 'image': $field->setSettings(['file_directory' => 'images', 'max_resolution' => '1080x1080']); break; case 'text_with_summary': case 'text_long': $field->setThirdPartySetting('allowed_formats', 'basic_html', 'basic_html'); break; } } 

This second hook alters the form display settings. The array_diff_key command is used to determine which fields are new.

/** * Implements hook_ENTITY_TYPE_presave(). * * Override field form display defaults used when a field is added to a content type. */ function XXX_entity_form_display_presave(EntityFormDisplay $display) { $fields = $display->getComponents(); $origFields = $display->original->getComponents(); foreach (array_diff_key($fields, $origFields) as $newField => $settings) { switch ($settings['type']) { case 'text_textarea_with_summary': case 'text_textarea': $settings['third_party_settings']['allowed_formats'] = ['hide_help' => '1', 'hide_guidelines' => '1']; $display->setComponent($newField, $settings); break; } } } 

Thanks to @Berdir and @4k4 who helped me out several times - I just followed their ideas, tested and wrote up the answers.

This first hook alters the field settings. I've included a second example for image settings.

function XXX_field_config_create(FieldConfigInterface $field) { if ($field->isSyncing()) return; switch ($field->getType()) { case 'image': $field->setSettings(['file_directory' => 'images', 'max_resolution' => '1080x1080']); break; case 'text_with_summary': case 'text_long': $field->setThirdPartySetting('allowed_formats', 'basic_html', 'basic_html'); break; } } 

This second hook alters the form display settings. The array_diff_key command is used to determine which fields are new.

/** * Implements hook_ENTITY_TYPE_presave(). * * Override field form display defaults used when a field is added to a content type. */ function XXX_entity_form_display_presave(EntityFormDisplay $display) { $fields = $display->getComponents(); $origFields = (isset($display->original)) ? $display->original->getComponents() : []; foreach (array_diff_key($fields, $origFields) as $newField => $settings) { switch ($settings['type']) { case 'text_textarea_with_summary': case 'text_textarea': $settings['third_party_settings']['allowed_formats'] = ['hide_help' => '1', 'hide_guidelines' => '1']; $display->setComponent($newField, $settings); break; } } } 
added 939 characters in body
Source Link
AdamS
  • 817
  • 7
  • 17
Loading
deleted 185 characters in body
Source Link
AdamS
  • 817
  • 7
  • 17
Loading
Rollback to Revision 1
Source Link
AdamS
  • 817
  • 7
  • 17
Loading
added 421 characters in body
Source Link
AdamS
  • 817
  • 7
  • 17
Loading
Source Link
AdamS
  • 817
  • 7
  • 17
Loading