Problem/Motivation
The Canvas Field Component module provides a mechanism for selecting a field in canvas as a component and apply the field's formatter settings to effectively determine how the field should be displayed. 2 issues have been discovered that are preventing custom fields from working as designed when selecting formatter settings.
- Canvas doesn’t support grouped options lists. This isn’t a big deal cause I can just check for form id and return flattened options list but this in particular shows an empty list currently for component selection: https://git.drupalcode.org/project/custom_field/-/blob/4.0.x/src/Plugin/...
- This one is a bigger issue and I havn’t been able to find a solution. It appears ajax calls in deeply nested form structures don’t seem to work and I think it has something to do on the react side in canvas. For example, the field selection here doesn’t work in canvas as it does when in normal manage display settings page: https://git.drupalcode.org/project/custom_field/-/blob/4.0.x/src/Plugin/.... Seems like the values selected are not preserved and passed through to all the frontend logic that handles the preview and such. The top level form selections seem to work fine so I’m guessing there are just some current limitations with Canvas form element recognition.
Steps to reproduce
- Create a custom field with various sub-fields for a particular entity type.
- In canvas, select the entity type from #1 and view mode to serve as content entity template
- Drag the custom field component into a canvas section
- Select the Single Directory Component formatter as the formatter type
- Acknowledge Issue #1, the component options field is empty even when there are eligible components available for selection because the options are grouped.
- If we flatten the options list, issue #2 is now in play. When we select a particular subfield for a slot for a component selected, acknowledge the ajax is in fact triggered but the selected field default value is not persisted and therefore the dependent sub-field formatter settings related to selected field are not correctly displayed.
Proposed resolution
- A work-around for issue #1 can live in custom_field or in canvas_field_component to flatten select list options. I will open a ticket in canvas_field_component as @mandclu has recommended to see if there's a generic fix that can be applied there for all select fields.
- Issue #2 needs discovery research to effectively find which module (custom_field, canvas_field_component, canvas) holds the source of truth for why nested form element ajax calls are not functioning as expected and when compared to normal field formatter settings in the manage display form separate from Canvas.
Remaining tasks
Research and testing.
User interface changes
Options list for component selection will be flattened to address issue #1
Issue fork custom_field-3592079
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