Skip to content

[Autocomplete] New autocomplete type #1158

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

Merged
merged 3 commits into from
Oct 6, 2023

Conversation

norkunas
Copy link
Contributor

@norkunas norkunas commented Oct 3, 2023

Q A
Bug fix? no
New feature? yes
Tickets #1129
License MIT

Continuation of work from @yceruto.

One thing that bothers me: in the ParentEntityAutocompleteType we have getBlockPrefix(): { return 'ux_entity_autocomplete'; }. If we'd add this to the new one, it'd break my custom form theme because I access form.autocomplete.vars.., should we set something new for block prefix?

Copy link
Member

@weaverryan weaverryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well... this is incredible. I tested locally - it works fantastically! So, I just think we need to:

A) Deprecate the old stuff - so ParentEntityAutocompleteType and AutocompleteEntityTypeSubscriber
B) Update the docs to show BaseEntityAutocompleteType

One thing that bothers me: in the ParentEntityAutocompleteType we have getBlockPrefix(): { return 'ux_entity_autocomplete'; }. If we'd add this to the new one, it'd break my custom form theme because I access form.autocomplete.vars.., should we set something new for block prefix?

Ah, I see what you're saying: if we return the same string, and your app has a mixture of old and new style fields, your one form theme will need to work for both situations. Are we sure we need to worry about this? When you start using the new way, you'll need to update your form theme anyway. And when you do, you can update all of your old usages to the new BaseEntityAutocompleteType or make your form theme temporarily a bit smarter to check to see if form.autocomplete is defineed. I'd vote for returning the same block prefix.

@norkunas norkunas force-pushed the new-autocomplete-type branch from f343202 to 5623a97 Compare October 4, 2023 03:52
@norkunas
Copy link
Contributor Author

norkunas commented Oct 4, 2023

Updated

Copy link
Member

@weaverryan weaverryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also update the docs? Probably updating all of the ParentEntityAuto... -> BaseEntityAuto... would be enough. Maybe also a versionadded to mention that BaseEntityAuto... is new in 2.13.

$container->prependExtensionConfig('twig', [
'form_themes' => ['@Autocomplete/autocomplete_form_theme.html.twig'],
]);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I think I misspoke & misunderstood what you were saying about the form theme stuff. We need to keep this (for the "old" system). For the new type, I'm leaning towards not returning ANY special block prefix and just allowing the normal one to be used for the entity type. If the user wants to theme something specifically for autocomplete entity types, I think they could probably do that via the uses_autocomplete form theme variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've restored the template but not to remove ux_entity_autocomplete block prefix, I've added checks to the template if we use new type or the old one and adapt

new Reference('router'),
])
->addTag('form.type');

$container
->register('ux.autocomplete.entity_type', ParentEntityAutocompleteType::class)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we deprecate this service? Or does that trigger a deprecation SIMPLY because it's a valid form type (even if it's unused)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deprecated

Copy link
Member

@weaverryan weaverryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Can you rebase and squash a little? I don't need 1 commit - but 2-3 would be fine. I can normally squash with our merge tool, but not with 2 authors - and we need a squash to remove that merge commit :)

@norkunas norkunas force-pushed the new-autocomplete-type branch 4 times, most recently from 19eda6d to 9ab50fc Compare October 6, 2023 03:36
@norkunas norkunas force-pushed the new-autocomplete-type branch from 9ab50fc to 9335587 Compare October 6, 2023 03:45
@norkunas
Copy link
Contributor Author

norkunas commented Oct 6, 2023

Rebase & squash done

@weaverryan
Copy link
Member

Thank you Tomas you seriously rock!

@weaverryan weaverryan merged commit f52d7af into symfony:2.x Oct 6, 2023
@norkunas norkunas deleted the new-autocomplete-type branch October 6, 2023 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants