Autocomplete inspector fields

Hi,
i’m trying to autocomplete inspector fields - case looks like this:

In component(snippet) i have properties like ‘url’, ‘description’, ‘upload_date’. When i provide ‘url’, request to API should be made which return data for the rest fields in inspector. Is there a possibility to run request to API when ‘url’ appear in inspector field and autocomplete these fields without adding some custom js?
I’ve found some documentation about inspector but it is mostly about frontend use of it, i want to use it in backend.

Hi and welcome @Mateusz,

The following is an example of using the autocomplete inspector type in a CMS component.

/**
 * KitchenSink is a pretend component
 */
class KitchenSink extends ComponentBase
{
    /**
     * defineProperties for the component
     */
    public function defineProperties()
    {
        return [
            'sortColumn' => [
                'title' => 'Sort by Column',
                'type' => 'autocomplete',
                // ...
            ],
        ];
    }

    /**
     * getSortColumnOptions for the autocomplete
     */
    public function getSortColumnOptions()
    {
        return [
            'create' => 'Create',
            'update' => 'Update',
            'delete' => 'Delete',
        ];
    }
}

I hope this helps!

Hi @daft , thanks :slight_smile: , i’m working with October for about a year - it is powerful and awesome :slight_smile:
i was trying to use autocomplete inspector type but for some reason it wont work as i expected - i’m getting a blank inspector field instead of options that i’ve defined in method.
If i change type to dropdown it’s working perfectly, maybe i have to enable something to be able to use autocomplete type?

Thanks for the kind feedback! Autocomplete will be blank until you type something in. Here is a screenshot of the implementation above:

Can you confirm what October CMS version you are using?

@daft i.m using version 2.2.34, but it’s not quite what i want to achieve. This autocomplete type is very handful in some situations, but i wanted to be able to autocomplete inspector fields without any user interaction (user will only provide url). Maybe i mispelled my initial question.
What i want to do is when i input url (like on a screen) the ‘description’ field will fill itself.
inspector
I think that this will not work without any ajax requests, that’s why i wanted to know if there is some build-in type which allows to do stuff like that.
The whole case should be like this:

  1. User provides url in ‘url’ field
  2. An API request is being made and returns with data to complete ‘description’ and other fields that i’ll add later
  3. ‘Description’ fields and rest of them completes by itself with data returning from server.

Hope that i didn’t mess up my comment too much :slight_smile:

Take a look at the depends property of the inspector configuration:

This could be more what you’re looking for.

@daft - Thanks! That was what i was looking for :slight_smile: now i’m a step closer to succed.
The only thing is that now i need to be able to edit somehow this autocompleted fields, but i’ll try to find my way on this.