Problem/Motivation
On field storage the form can be submitted even the "Comment type" dropdown shows no entries. This creates a comment field with an empty comment_type.
Steps to reproduce
- Go to: Admin > Structure > Taxonomy
- Create a new vocabulary
- On the new vocabulary page click the "Manage fields" tab, then click "Add field"
- Select "Comment" from "Add a new field" dropdown, fill a field name and press "Save and continue"
- Note that the "Comment type" select is empty.
You cannot submit this form because the field has no value but if you go back to the "Manage fields" page (may requirrefresh), you'll note tha the field has been added.
Comments
Comment #4
larowlanI think this is because \Drupal\comment\Plugin\Field\FieldType\CommentItem::defaultStorageSettings defaults to an empty string
Perhaps we should try to find a valid comment type instead?
Comment #5
joachim commented> Perhaps we should try to find a valid comment type instead?
There will typically be no valid comment type, as the user is unlikely to know that they need to create the comment type first.
Comment #8
lauriiiThe creation of invalid field storage config entity is possible because of #2327883: Field [storage] config have incomplete settings until they are saved and #3324140: Convert field_storage_config and field_config's form validation logic to validation constraints. We will probably address part of this in #3358049: Save FieldStorageConfig at the same time as FieldConfig because you wouldn't be able to pass the second step. However, we could potentially further improve the UX by adding validation to the first step that would only allow adding the field if there are valid comment types.
Comment #9
wim leersThanks for surfacing this one, @lauriii!
Comment #10
wim leersPostponing on #3324140: Convert field_storage_config and field_config's form validation logic to validation constraints, after which it'll become trivial to fix this! 😊
Comment #12
herved commentedI discovered an issue in
CommentLinksTest.phprevealed by #2879087-148: Use comment access handler instead of hardcoding permissionsThere are other cases in tests where the comment type is not created.