# Handling Relations to Collections
Considering an API exposing `Person` and `Book` resources linked with a `many-to-many`
relation between them (through the `authors` property).
This API using the following PHP code:
```php
authors = new ArrayCollection();
}
}
```
The admin handles this `to-many` relation automatically!
## Customizing a Property
Let's customize the components used for the `authors` property, to display them by their 'name' instead 'id' (the default behavior).
```javascript
import React, { Component } from 'react';
import { ReferenceArrayField, SingleFieldList, ChipField, ReferenceArrayInput, SelectArrayInput } from 'react-admin';
import { AdminBuilder, hydraClient } from '@api-platform/admin';
import parseHydraDocumentation from '@api-platform/api-doc-parser/lib/hydra/parseHydraDocumentation';
const entrypoint = 'https://demo.api-platform.com';
export default class extends Component {
state = { api: null }
componentDidMount() {
parseHydraDocumentation(entrypoint).then(({api}) => {
const books = api.resources.find(({ name }) => 'books' === name)
const authors = books.fields.find(({ name }) => 'authors' === name)
// Set the field in the list and the show views
authors.field = props => (
);
// Set the input in the edit and create views
authors.input = props => (
);
this.setState({ api });
}
)
}
render() {
if (null === this.state.api) return
Loading...
;
return
}
}
```
## Customizing an Icon
Now that our `authors` property is displaying the name instead of an 'id', let's change the icon shown in the list menu.
Just add an import statement from `@material-ui` for adding the icon, in this case, a user icon:
`import UserIcon from '@material-ui/icons/People';`
and add it to the `authors.icon` property
The code for just customizing the icon will be:
```javascript
import React, { Component } from 'react';
import { AdminBuilder, hydraClient } from '@api-platform/admin';
import parseHydraDocumentation from '@api-platform/api-doc-parser/lib/hydra/parseHydraDocumentation';
import UserIcon from '@material-ui/icons/People';
const entrypoint = 'https://demo.api-platform.com';
export default class extends Component {
state = { api: null }
componentDidMount() {
parseHydraDocumentation(entrypoint).then(({api}) => {
const authors = books.fields.find(({ name }) => 'authors' === name)
// Set the icon
authors.icon = UserIcon
this.setState({ api });
}
)
}
render() {
if (null === this.state.api) return Loading...
;
return
}
}
```
## Using an Autocomplete Input for Relations
We'll make one last improvement to our admin: transforming the relation selector we just created to use autocompletion.
Start by adding a "partial search" filter on the `name` property of the `Book` resource class.
```yaml
# api/config/services.yaml
services:
person.search_filter:
parent: 'api_platform.doctrine.orm.search_filter'
arguments: [ { name: 'partial' } ]
# Uncomment only if you don't use autoconfiguration
#tags: ['api_platform.filter']
```
```php
(
({ name: searchText })} {...props} allowEmpty>
);
// ...
}
```
The autocomplete field should now work properly!