Skip to content

Commit

Permalink
Do not output text type when product is simple
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Dec 12, 2024
1 parent 7d8beb2 commit 8fc2fcc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/Form/Type/WishlistItemType.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void

$form = $event->getForm();

if ($product->isSimple()) {
$form->add('variant', TextType::class, [
'disabled' => true,
]);
} else {
if (!$product->isSimple()) {
$form->add('variant', ProductVariantChoiceType::class, [
'choice_label' => fn (ProductVariantInterface $variant) => implode(', ', array_map(static fn ($optionValue) => sprintf('%s: %s', (string) $optionValue->getOption()?->getName(), (string) $optionValue->getValue()), $variant->getOptionValues()->toArray())),
'placeholder' => 'setono_sylius_wishlist.ui.select_variant',
Expand Down
4 changes: 3 additions & 1 deletion src/Resources/views/shop/wishlist/show.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@
</td>
<td>
<div class="ui form">
{{ form_widget(form.items[key].variant) }}
{% if form.items[key].variant is defined %}
{{ form_widget(form.items[key].variant) }}
{% endif %}
</div>
</td>
<td>
Expand Down

0 comments on commit 8fc2fcc

Please sign in to comment.