-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Admin][Product] Add ProductAttribute autocomplete type
- Loading branch information
1 parent
2310f81
commit 480cfca
Showing
3 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
src/Sylius/Bundle/AdminBundle/Form/Type/ProductAttributeAutocompleteChoiceType.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Sylius Sp. z o.o. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Bundle\AdminBundle\Form\Type; | ||
|
||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
use Symfony\UX\Autocomplete\Form\AsEntityAutocompleteField; | ||
use Symfony\UX\Autocomplete\Form\BaseEntityAutocompleteType; | ||
|
||
#[AsEntityAutocompleteField(route: 'sylius_admin_entity_autocomplete_admin')] | ||
final class ProductAttributeAutocompleteChoiceType extends AbstractType | ||
{ | ||
public function __construct( | ||
private readonly string $productAttributeClass, | ||
) { | ||
} | ||
|
||
public function configureOptions(OptionsResolver $resolver): void | ||
{ | ||
$resolver->setDefaults([ | ||
'class' => $this->productAttributeClass, | ||
'choice_name' => 'name', | ||
'choice_value' => 'code', | ||
]); | ||
} | ||
|
||
public function getBlockPrefix(): string | ||
{ | ||
return 'sylius_admin_product_attribute_autocomplete_choice'; | ||
} | ||
|
||
public function getParent(): string | ||
{ | ||
return BaseEntityAutocompleteType::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters