Yii2 3 Autocomplete Linked.

I am redoing a quotation system, where the user should pick the company, then the state and then the contact.

I know how to populate the autocomplete, but I still don’t know how to “CHAIN” them.

Anyone doing something similar ?

It’s pretty simple, you just listen to onchange (or whatever you have) event and rebuild the interface accordingly.

Element N is empty and disabeld until first N-1 elements are set.

PS. Since client-side logic can become complicated very soon (this and that is selected, so these should be active and these invisible) it’s worth to use some helper libraries, like knockout.

If you are looking for a premade solution - with a dropdown list instead of autocomplete… recently added a new Dependent Dropdown widget. This is a Yii 2 wrapper for the Krajee dependent-dropdown jQuery plugin. Allows multi level dependent dropdown setup with nested dependencies.

Alternatively, use a ajax call to pull in the dependent list of data from the server and overwrite the HTML markup as Orey mentioned.

Thanks for both :).

For now I am using an ajax call on the change on the autocomplete. I will investigate more on the dependent driodown later.

Take care!