diff --git a/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php b/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php index 71c6b49e54415133d7172086cce092a8f3c8bd7b..66b5dd1343c2d6bc47b5a4c85cd8329ddb3fc520 100644 --- a/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php +++ b/src/Plugin/Field/FieldWidget/InlineEntityFormComplex.php @@ -16,6 +16,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Render\Element; +use Drupal\Core\Render\Markup; use Drupal\inline_entity_form\TranslationHelper; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -493,13 +494,16 @@ class InlineEntityFormComplex extends InlineEntityFormBase implements ContainerF } } else { - $row = &$element['entities'][$key]; + // This is needed for accessibility. + $weight_label = '<span class="visually-hidden">' . $this->t( 'Weight for row @number', [ '@number' => $key ] ) . '</span>'; + $row = &$element['entities'][ $key ]; $row['title'] = []; $row['delta'] = [ - '#type' => 'weight', - '#delta' => $weight_delta, + '#type' => 'weight', + '#title' => Markup::create( $weight_label ), + '#delta' => $weight_delta, '#default_value' => $value['weight'], - '#attributes' => ['class' => ['ief-entity-delta']], + '#attributes' => [ 'class' => [ 'ief-entity-delta' ] ], ]; // Add an actions container with edit and delete buttons for the entity. $row['actions'] = [