Skip to content
Snippets Groups Projects

Issue #3516520 Add language default value

Open Lee Rowlands requested to merge issue/drupal-3516520:3516520-languageitem-lacks-a into 11.x
1 unresolved thread

Closes #3516520

Merge request reports

Members who can merge are allowed to add commits.
Approval is optional
Ready to merge by members who can write to the target branch.

Merge details

  • The source branch is 264 commits behind the target branch.
  • 12 commits and 1 merge commit will be added to .
  • Source branch will not be deleted.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
940 940 type: timestamp
941 941 label: 'Value'
942 942
943 field.value.language:
944 type: mapping
945 label: 'Language value'
946 mapping:
947 value:
948 type: string
949 label: 'Language value'
  • Comment on lines +948 to +949

    Looking at \Drupal\Core\Field\Plugin\Field\FieldWidget\LanguageSelectWidget::formElement() and \Drupal\Core\Field\Plugin\Field\FieldType\LanguageItem::generateSampleValue(), the allowed set of lang really depends on configuration, but nonetheless, this is currently accepting arbitrary strings, when we could be restricting it to actual langcodes at least:

    Suggested change
    949 type: string
    950 label: 'Language value'
    949 type: langcode
    950 label: 'Language value'
  • Good point!

    But could this be also empty/null?

    Because langcode has a NotNull constraint, and getAllValidLangcodes() wouldn't allow an empty string

    langcode:
      type: string
      label: 'Language code'
      constraints:
        NotNull: []
        Choice:
          callback: 'Drupal\Core\TypedData\Plugin\DataType\LanguageReference::getAllValidLangcodes'
  • Please register or sign in to reply
  • Wim Leers requested changes

    requested changes

  • Lee Rowlands added 7 commits

    added 7 commits

    Compare with previous version

  • Please register or sign in to reply
    Loading