ux icon indicating copy to clipboard operation
ux copied to clipboard

[LiveComponent] Document how to use `extra_options` in the Ajax-powered autocomplete

Open jakubtobiasz opened this issue 1 year ago • 7 comments

Q A
Bug fix? no
New feature? n/a
Issues requested in https://github.com/symfony/ux/pull/1322#issuecomment-1986102279
License MIT

Time spent on this PR has been sponsored by Commerce Weavers ♥️.

jakubtobiasz avatar Apr 09 '24 06:04 jakubtobiasz

Thanks @jakubtobiasz ! I'll make some minor comments / suggestions tonight, but this is very welcome !

smnandre avatar Apr 09 '24 12:04 smnandre

@smnandre I believe there're might be some places to be improved, as I'm not the best to write docs, especially if most of them have some kind of standarization :D. So I'm open for any comments 🙌🏻.

jakubtobiasz avatar Apr 09 '24 13:04 jakubtobiasz

A more sensible point here: i'd really like to warn users those values will be "readable" from front... or are they encoded i don't remember what choice was made in the end ?

smnandre avatar Apr 09 '24 17:04 smnandre

@jakubtobiasz Thanks for this PR.

In my use case, we need to overwrite the label. I solved it with this Code, and i think this is useful for others as well. Maybe you can add this to the PR? Otherwise i can add a PR after this is merged.

#[AsEntityAutocompleteField]
class FooAutocompleteField extends AbstractType
{
    public function buildView(FormView $view, FormInterface $form, array $options): void
    {
        if(isset($options['extra_options']['label'])) {
            $view->vars['label'] = $options['extra_options']['label'];
        }
    }
class FooFormType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
      $builder->add('bar', FooAutocompleteField::class, ['extra_options' => ['label' => 'Overwritten Label']]);
   }
  ...
}

Chris53897 avatar Apr 24 '24 12:04 Chris53897

@jakubtobiasz do you need some help here ?

smnandre avatar Jun 05 '24 18:06 smnandre

@smnandre being honest, this PR just fell out of my head 😅; I'll try to finalize it this ASAP.

jakubtobiasz avatar Jun 07 '24 19:06 jakubtobiasz

No hurry, and if i can help in any way please ask ;)

smnandre avatar Jun 07 '24 19:06 smnandre

@smnandre Finally I've got some time (thanks to Commerce Weavers) to finish this PR. I've left comments unresolved, so feel free to resolve them once you decide a given issue is resolved.

jakubtobiasz avatar Jul 29 '24 11:07 jakubtobiasz

I'll check later this week, but already a big thank you !

smnandre avatar Jul 29 '24 22:07 smnandre

I've left comments unresolved, so feel free to resolve them once you decide a given issue is resolved.

I have no button for this (or i don't know where to find them) 😅

But all good for me, a big big thank you :)

smnandre avatar Jul 30 '24 21:07 smnandre

Thank you Jacob.

kbond avatar Jul 31 '24 13:07 kbond