Skip to content
Snippets Groups Projects
Commit 0e05aff2 authored by Edmund Dunn's avatar Edmund Dunn Committed by Andrii Podanenko
Browse files

Issue #3311501 by edmund.dunn, geek-merlin: Add label to weight select field for accessibility

parent fbdde8ba
Branches
Tags
No related merge requests found
......@@ -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'] = [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment