Problem/Motivation
Currently there's no real template suggestions for form elements created by a form with a base form since the form_id is unique for each form.
For the drupal commerce add to cart form the suggestions generated are:
<!-- FILE NAME SUGGESTIONS:
* form-element-label--commerce-order-item-add-to-cart-form-commerce-product-4031--select.html.twig
* form-element-label--form-id--commerce-order-item-add-to-cart-form-commerce-product-4031.html.twig
* form-element-label--type--select.html.twig
x form-element-label.html.twig
-->
Proposed resolution
The attached patch looks for a base id in the form state and if it's there adds suggestions.
With the patch applied the suggestions generated for the add to cart form are:
<!-- FILE NAME SUGGESTIONS:
* form-element--commerce-order-item-add-to-cart-form-commerce-product-4031--select.html.twig
* form-element--form-id--commerce-order-item-add-to-cart-form-commerce-product-4031.html.twig
* form-element--commerce-order-item-add-to-cart-form--select.html.twig
* form-element--form-id--commerce-order-item-add-to-cart-form.html.twig
* form-element--type--select.html.twig
x form-element.html.twig
-->
Comments
Comment #2
ctrladelComment #3
tgaugesThe previous patch did not apply to version beta2, here is my updated patch for version 8.x-1.0-beta2.