Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 89fb2d2

Browse files
committed
bug EasyCorp#6740 Bug EasyCorp#5161 Disallow clear in AssociationField when field is required (Sobak)
This PR was merged into the 4.x branch. Discussion ---------- Bug EasyCorp#5161 Disallow clear in AssociationField when field is required Hi, This small change closes EasyCorp#5161 and instructs the frontend library to not render the `x` button for unsetting the association completely. Admittedly, "extending" the trait methods in PHP is always weird and it's not very common, but it allows for the least amount of code repetition. This approach also doesn't require any JS changes. Please let me know if such approach is acceptable. This is my first contribution so there might be some other rules that I'm not aware of. Thanks! Commits ------- 20ff3e4 bug EasyCorp#5161 Disallow clear in AssociationField when field is required
2 parents af278aa + 20ff3e4 commit 89fb2d2

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

src/Field/Configurator/CommonPreConfigurator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function configure(FieldDto $field, EntityDto $entityDto, AdminContext $c
6464

6565
$isRequired = $this->buildRequiredOption($field, $entityDto);
6666
$field->setFormTypeOption('required', $isRequired);
67+
$field->setHtmlAttribute('required', $isRequired);
6768

6869
$isSortable = $this->buildSortableOption($field, $entityDto);
6970
$field->setSortable($isSortable);

0 commit comments

Comments
 (0)