Problem/Motivation
When Schema.org Blueprints creates Custom Field sub-field allowed_values, the saved option rows use key and value.
The Custom Field module expects option rows to use key and label. Because of this mismatch, the keys are present on the field settings form but the label inputs are empty.
Observed at:
/admin/structure/types/manage/person/fields/node.person.schema_contact_point
For the Contact Point contact_type sub-field, the option keys are created as mobile, home, and work, but their labels are blank.
Steps to reproduce
- Install Schema.org Blueprints with
schemadotorg_custom_field. - Create or inspect the Person content type mapping with the Contact Point custom field.
- Visit
/admin/structure/types/manage/person/fields/node.person.schema_contact_point. - Expand the
contact_typesub-field settings. - Inspect the allowed values table.
Proposed resolution
Use Custom Field's expected allowed_values shape:
[
'key' => 'mobile',
'label' => 'Mobile',
]instead of:
[
'key' => 'mobile',
'value' => 'Mobile',
]Also update SchemaDotOrgCustomFieldJsonLdManager::schemaPropertyAlter() to read label when converting selected custom field values to JSON-LD labels.
Remaining tasks
- Create an issue fork.
- Open a merge request with the fix.
- Review test coverage.
User interface changes
Allowed value labels appear in Custom Field sub-field settings instead of blank label inputs.
API changes
None.
Data model changes
None.
Test result
ddev phpunit web/modules/sandbox/schemadotorg/modules/schemadotorg_custom_field/tests/src/Kernel/SchemaDotOrgCustomFieldManagerKernelTest.php web/modules/sandbox/schemadotorg/modules/schemadotorg_custom_field/tests/src/Kernel/SchemaDotOrgCustomFieldJsonLdKernelTest.php web/modules/sandbox/schemadotorg/modules/schemadotorg_custom_field/tests/src/Kernel/SchemaDotOrgCustomFieldRoleJsonLdKernelTest.phpResult:
Tests: 4, Assertions: 101 OK, but there were issues! Deprecations: 20, PHPUnit Deprecations: 7.
Issue fork schemadotorg-3593347
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
jrockowitz commented