Giter Site home page Giter Site logo

usefulbundle's Introduction

ResomediaUsefulBundle 3 - autocomplete easy

Fork from ShtumiUsefulBundle

Installation

Add the following lines to your deps file and then run php bin/vendors install:

"resomedia/useful-bundle": "3.*"

Add ResomediaUsefulBundle to your application kernel

    // app/AppKernel.php
    public function registerBundles()
    {
        return array(
            // ...
            new Resomedia\UsefulBundle\ResomediaUsefulBundle(),
            // ...
        );
    }

Import routes

resomedia_useful:
    resource: "@ResomediaUsefulBundle/Controller/"
    type: annotation

Add form theming to twig (you can override this view)

twig:
    ...
    form_theme:
            - 'ResomediaUsefulBundle:Form:fields_useful.html.twig'

Load jQuery to your views and this

    <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>

###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. Clean code

usefulbundle's People

Contributors

demo-git avatar shtumi avatar smoya avatar raphaelm avatar planimmobilier avatar mahi1881 avatar nucleartux avatar cedcannes avatar maikelohcfg avatar pabloveintimilla avatar toothfairy avatar vhpoet avatar grifx avatar inalgnu avatar mewlabs avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.