Fork from ShtumiUsefulBundle
"resomedia/useful-bundle": "5.*"
// config/bundles.php
return [
// ...
Resomedia\UsefulBundle\ResomediaUsefulBundle::class => ['all' => true],
// ...
];
resomedia_useful:
resource: "@ResomediaUsefulBundle/Controller/"
type: annotation
twig:
...
form_theme:
- 'ResomediaUseful/Form/fields_useful.html.twig'
<script type="text/javascript" src="{{ asset('bundles/resomediauseful/js/bootstrap3-typeahead.min.js') }}"></script>
<script type="text/javascript" src="{{ asset('bundles/resomediauseful/js/useful.js') }}"></script>
<script type="text/javascript" src="{{ asset('bundles/resomediauseful/js/autocomplete.js') }}"></script>
<script type="text/javascript" src="{{ asset('bundles/resomediauseful/js/useful-bootstrap.js') }}"></script>
###Configuration
// app/config/config.yml
resomedia_useful:
autocomplete_entities:
users:
class: AcmeDemoBundle:User
choice_label: fullname
role: ROLE_ADMIN
property: email
where: 'activate = 1'
encrypted: true
products:
class: AcmeDemoBundle:Product
choice_label: name
role: ROLE_ADMIN
search: contains|ends_with|begins_with
case_insensitive: true
- class - Doctrine model.
- role - User role to use form type. Default: IS_AUTHENTICATED_ANONYMOUSLY. It needs for security reason.
- choice_label - Property that will be prompted by autocomplete. Default: title.
- search - LIKE format to get autocomplete values. You can use:
- begins_with - LIKE 'value%' (default)
- ends_with - LIKE '%value'
- contains - LIKE '%value%'
- where - your condition
- case_insensitive - Whether or not matching should be case sensitive or not
- encrypted - true / false, if your field is encrypt. (Soon)
###Usage
$formBuilder->add('user', AjaxAutocompleteType::class, array(
'entity_alias' => 'users',
'label' => 'search user',
'required' => false,
'attr' => array('class' => 'form-control')
));
###V3.0 It is a lite version with only ajax autocomplete. But the documentation is up to date and add symfony3 compatibility. For more tools in UsefulBundle check ShtumiUsefulBundle. ###V4.0 Add symfony4 compatibility. ###V5.0 Add symfony5 compatibility. Add vanilla JS for bootstrap 5