Support programmatically setting a field default value

Created on 27 June 2020, over 4 years ago
Updated 11 August 2024, 3 months ago

It would be nice if custom code could add an appropriate default group for new entity forms, so users don't have to do anything unless they want to change it.

Ideally there would be a simple static method or setting to do so, accessed from hook_field_widget_WIDGET_TYPE_form_alter().

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇳🇿New Zealand john pitcairn

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇪🇸Spain aleix

    Sorry to necrobumping this, but I think that there's a use case: Imagine a course group that has chapters and resources as group content, resources are created in chapters through inline entity form, but they need to be added to group too. So a clean way may be to add entitygroupfield prepopulated from ief form alter getting the route parameters. Now is so difficult to reach there from form alter, so the same way the form element has 'excluded_groups' it could have the 'preselected_groups' element property.
    This use case is also there when there are references to media in group content that must be confined to group it's commonly desired to inherit the group relationship from parent content.

  • 🇪🇸Spain aleix

    After trying to integrate the feature request in previous comment I end up creating a module with simplified behavior: a simple checkbox to relate the referenced entities if possible it could be found here: https://www.drupal.org/project/group_relationship_inheritance , sorry for the noise guys.

Production build 0.71.5 2024