ux icon indicating copy to clipboard operation
ux copied to clipboard

[Autocomplete] Autocomplete URL must be provided without attribute

Open norkunas opened this issue 2 years ago • 5 comments

Currently when using #[AsEntityAutocompleteField] route ux_entity_autocomplete is automatically configured if not explicitly provided. Would be nice to have a possibility also to use this default when just tagging via service config:

<?php

declare(strict_types=1);

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Symfony\UX\Autocomplete\DependencyInjection\AutocompleteFormTypePass;

return static function (ContainerConfigurator $container): void {
    $container->services()
        ->defaults()
            ->private();

    $container->services()
        ->set('custom_autocomplete_field', CustomAutocompleteField::class)
            ->tag('form.type')
            ->tag(AutocompleteFormTypePass::ENTITY_AUTOCOMPLETE_FIELD_TAG, ['alias' => 'custom'])
    ;
};

Or at least to provide it via AutocompleteFormTypePass::ENTITY_AUTOCOMPLETE_FIELD_TAG tag attribute otherwise in each AutocompleteField I need to inject UrlGenerator and generate the url because ParentEntityAutocompleteType expects autocomplete_url to be absolute.

norkunas avatar Jun 30 '23 05:06 norkunas

Hey @norkunas!

Can you explain what you're proposing a bit more?

Currently when using #[AsEntityAutocompleteField] route ux_entity_autocomplete is automatically configured if not explicitly provided.

This route is never automatically added - it's imported by the user via https://github.com/symfony/recipes/blob/main/symfony/ux-autocomplete/2.6/config/routes/ux_autocomplete.yaml - so I think you mean something else, but I'm not sure what it is :)

Maybe you can post some code you currently need to write and show how you'd like it to be different.

Cheers!

weaverryan avatar Jun 30 '23 18:06 weaverryan

Yes, I know that it's imported by user, but the attribute carries default route name,so I think it should be same when just tagging it manually :)

norkunas avatar Jun 30 '23 18:06 norkunas

Thank you for this issue. There has not been a lot of activity here for a while. Has this been resolved?

carsonbot avatar Apr 25 '24 12:04 carsonbot

Not resolved

norkunas avatar Apr 25 '24 12:04 norkunas

Thank you for this issue. There has not been a lot of activity here for a while. Has this been resolved?

carsonbot avatar Oct 26 '24 12:10 carsonbot

Just a quick reminder to make a comment on this. If I don't hear anything I'll close this.

carsonbot avatar Nov 09 '24 12:11 carsonbot

Hey,

I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen!

carsonbot avatar Nov 23 '24 12:11 carsonbot