sonata-project/SonataAdminBundle — pull request #1764 by pulzarraider (2013-10-27 18:53:28+00:00)
Title: [WIP] Added sonata_type_model_autocomplete form type

``sonata_type_model_autocomplete`` is additional model form type for ``sonata_type_model`` and ``sonata_type_model_list`` for handling many-to-one relations.

I've created it because ``sonata_type_model`` can't be used for too many items and ``sonata_type_model_list`` is not ideal for some use cases.

Usage is very simple:

```php
// e-mail is a property from related User entity, on which we will filter the data
$formMapper->add('user', 'sonata_type_model_autocomplete', array('property'=>'eMail'));

// or if you need change the query, you can specify callback option
$formMapper->add('user', 'sonata_type_model_autocomplete',
array(
'property'=>'eMail',
'callback'=>function($queryBuilder, $alias, $property, $value){
$queryBuilder->andWhere($alias.'.enabled=1');
}));

// there are additional options, like ``url``, ``route_name``, ``placeholder``, ``minimum_input_length``, ``items_per_page`` ...
```
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #1172, #1758, partially #633
| License | MIT
| Doc PR | -

TODO:
- documementation
- basic tests