Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

jakubtobiasz
Copy link
Contributor

@jakubtobiasz jakubtobiasz commented Apr 9, 2024

Q A
Bug fix? no
New feature? n/a
Issues requested in #1322 (comment)
License MIT

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

@carsonbot carsonbot added the Status: Needs Review Needs to be reviewed label Apr 9, 2024
@jakubtobiasz jakubtobiasz force-pushed the autocomplete_extra_options_docs branch from a06528b to f57c765 Compare April 9, 2024 07:43
@smnandre
Copy link
Member

smnandre commented Apr 9, 2024

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

@jakubtobiasz
Copy link
Contributor Author

@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 🙌🏻.

@smnandre
Copy link
Member

smnandre commented Apr 9, 2024

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 ?

@Chris53897
Copy link
Contributor

@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']]);
   }
  ...
}

@smnandre
Copy link
Member

smnandre commented Jun 5, 2024

@jakubtobiasz do you need some help here ?

@jakubtobiasz
Copy link
Contributor Author

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

@smnandre
Copy link
Member

smnandre commented Jun 7, 2024

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

@jakubtobiasz jakubtobiasz force-pushed the autocomplete_extra_options_docs branch from f57c765 to aab8892 Compare July 29, 2024 11:09
@jakubtobiasz
Copy link
Contributor Author

@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.

@smnandre
Copy link
Member

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

@smnandre
Copy link
Member

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 :)

@carsonbot carsonbot added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Review Needs to be reviewed labels Jul 30, 2024
@kbond
Copy link
Member

kbond commented Jul 31, 2024

Thank you Jacob.

@kbond kbond merged commit c1befad into symfony:2.x Jul 31, 2024
2 checks passed
@jakubtobiasz jakubtobiasz deleted the autocomplete_extra_options_docs branch August 2, 2024 12:14
kbond added a commit that referenced this pull request Aug 13, 2024
…efebvre)

This PR was squashed before being merged into the 2.x branch.

Discussion
----------

fix: warning and code formatting on Autocomplete

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| Issues        | -
| License       | MIT

Fix broken formatting on https://symfony.com/bundles/ux-autocomplete/current/index.html#passing-extra-options-to-the-ajax-powered-autocomplete

Current result:

> ![image](https://github.com/user-attachments/assets/cd7d7105-cf31-4bca-9374-29e8b3f49ebf)

Follow-up of:

- #1702

Commits
-------

58dbf49 fix: warning and code formatting on Autocomplete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Reviewed Has been reviewed by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants