All Projects โ†’ Alsatian67 โ†’ FormBundle

Alsatian67 / FormBundle

Licence: MIT license
Bunch of FormTypes extending some basic Symfony PHP framework FormTypes. ExtensibleTypes makes it possible to allow extra choices by Symfony ChoiceTypes (ChoiceType, EntityType and DocumentType). This can help to make it work with the Select2 jQuery pluggin.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to FormBundle

laravel-admin-select2
๐’‚๐’”๐’š๐’๐’„ ๐’”๐’†๐’๐’†๐’„๐’•/๐’Ž๐’๐’“๐’‘๐’‰๐‘บ๐’†๐’๐’†๐’„๐’• ๐’‡๐’๐’“ ๐’๐’‚๐’“๐’‚๐’—๐’†๐’ ๐’‚๐’…๐’Ž๐’Š๐’
Stars: โœญ 42 (+200%)
Mutual labels:  select2
Select2
Select2 is a jQuery based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results.
Stars: โœญ 25,184 (+179785.71%)
Mutual labels:  select2
Stf Vue Select
stf vue select - most flexible and customized select
Stars: โœญ 61 (+335.71%)
Mutual labels:  select2
select2-to-tree
Select2-to-Tree extends Select2 to support arbitrary level of nesting...
Stars: โœญ 71 (+407.14%)
Mutual labels:  select2
Cc
ไธ€ไธชๅŸบไบŽangular5.0.0+ng-bootstrap1.0.0-beta.8+bootstrap4.0.0-beta.2+scss็š„ๅŽๅฐ็ฎก็†็ณป็ปŸ็•Œ้ข(ๆฒกๅŸบ็ก€็š„ๅŒๅญฆ่ฏทๅ…ˆ่‡ชๅญฆๅŸบ็ก€๏ผŒ่ฐข่ฐข๏ผ)
Stars: โœญ 416 (+2871.43%)
Mutual labels:  select2
Select2 Bootstrap Theme
A Select2 v4 Theme for Bootstrap 3
Stars: โœญ 841 (+5907.14%)
Mutual labels:  select2
vue-select2
select2 component in vue.
Stars: โœญ 109 (+678.57%)
Mutual labels:  select2
React Select2 Wrapper
Wrapper for Select2
Stars: โœญ 163 (+1064.29%)
Mutual labels:  select2
Choices
A vanilla JS customisable select box/text input plugin โšก๏ธ
Stars: โœญ 4,505 (+32078.57%)
Mutual labels:  select2
Danyuan Application
ๅˆๅญฆ่€… spirng-boot็‰ˆๆœฌ
Stars: โœญ 47 (+235.71%)
Mutual labels:  select2
django-select2
This is a Django integration for Select2
Stars: โœญ 73 (+421.43%)
Mutual labels:  select2
Select2 Bootstrap4 Theme
Select2 v4 theme for Bootstrap4
Stars: โœญ 305 (+2078.57%)
Mutual labels:  select2
Laravel Dusk Select2
Select2.js support for the Laravel Dusk testing
Stars: โœญ 31 (+121.43%)
Mutual labels:  select2
laravel-simple-select
Laravel Simple Select inputs component for Blade and Livewire.
Stars: โœญ 59 (+321.43%)
Mutual labels:  select2
Countrycity
๐ŸŒŽ Geodata API - Get countries, and cities to plug in a select drop-down.
Stars: โœญ 62 (+342.86%)
Mutual labels:  select2
select2-wire
free select2 livewire for laravel
Stars: โœญ 18 (+28.57%)
Mutual labels:  select2
Angular Select2
select2 in angular(>=2.0-release).
Stars: โœญ 16 (+14.29%)
Mutual labels:  select2
Django Easy Select2
Select2 input widget for django selectable fields.
Stars: โœญ 165 (+1078.57%)
Mutual labels:  select2
Select2 Bootstrap4 Theme
A theme for Select2 v4 and Bootstrap 4
Stars: โœญ 97 (+592.86%)
Mutual labels:  select2
Laravel Nova Select2 Auto Complete
Laravel Nova Select2 Auto-Complete
Stars: โœญ 34 (+142.86%)
Mutual labels:  select2

FormBundle

This bundle provide FormTypes extending ChoiceType, EntityType and DocumentType to let them accept additional choices added on the client side.

Ideal for Select2 integration.

Use version 1.1 for Symfony >= 4.4 Use version 1.0 for Symfony 2.8 to 4.3

Features

The bundle provide 6 FormTypes designed to automate some common tasks :

  • ExtensibleChoiceType : Extension for the built-in ChoiceType

    Choice type which starts with an empty HTML select and accept each submitted choice which has be added on the client side.

    • Configuration : Insert %alsatian_form.parameters.extensible_choice.attr_class% as class for the HTML select.
    • Options : 'route' and 'route_params' to render a data-ajax--url tag in the HTML select.
  • ExtensibleEntityType : Extension for the built-in EntityType

    Entity type type which starts with an empty HTML select and accept each existing entity which has be added on the client side.

    • Configuration : Insert %alsatian_form.parameters.extensible_entity.attr_class% as class for the HTML select.
    • Options : 'route' and 'route_params' to render a data-ajax--url tag in the HTML select.
  • ExtensibleDocumentType : Extension for the DoctrineMongoDBBundle DocumentType

    Document type which starts with an empty HTML select and accept each existing document which has be added on the client side.

    • Configuration : Insert %alsatian_form.parameters.extensible_document.attr_class% as class for the HTML select.
    • Options : 'route' and 'route_params' to render a data-ajax--url tag in the HTML select.
  • AutocompleteType : Extension for the built-in TextType

    Text type allowing to add some html attributes to expose ajax route for autocompletion.

    • Configuration : Insert %alsatian_form.parameters.autocomplete.attr_class% as class for the HTML input.
    • Options : 'route' and 'route_params' to render a data-ajax--url tag in the HTML input.
  • DatepickerType : Extension for the built-in DateType

    Date type where the date pattern is rendered as 'pattern' attribute in the HTML input (Using \IntlDateFormatter::SHORT).

    • Configuration : Insert %alsatian_form.parameters.date_picker.attr_class% as class for the HTML input.
  • DateTimepickerType : Extension for the built-in DateTimeType

    DateTime type where the date pattern is rendered as 'pattern' attribute in the HTML input (Using \IntlDateFormatter::SHORT).

    • Configuration : Insert %alsatian_form.parameters.datetime_picker.attr_class% as class for the HTML input.

Installation

Download the bundle with composer

    composer require alsatian/form-bundle

Enable the bundle

Add the bundle to app/AppKernel.php :

// app/AppKernel.php

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new Alsatian\FormBundle\AlsatianFormBundle(),
        );

        // ...
    }

    // ...
}

Configuration

Add following lines to app/config/config.yml

alsatian_form:
    extensible_choice: ~   # To enable Alsatian\FormBundle\Form\ExtensibleChoiceType
    extensible_entity: ~   # To enable Alsatian\FormBundle\Form\ExtensibleEntityType
    extensible_document: ~ # To enable Alsatian\FormBundle\Form\ExtensibleDocumentType

For each FormType you can configure a default attr_class parameter, like this :

alsatian_form:
    extensible_choice:
        attr_class: select2 # Adds class="select2" in the HTML select element
    extensible_entity:
        attr_class: select2-entity # Adds class="select2-entity" in the HTML select element
    extensible_document:
        attr_class: select2-document # Adds class="select2-document" in the HTML select element

Usage

To use these FormTypes :

    use Alsatian\FormBundle\Form\ExtensibleChoiceType;
    use Alsatian\FormBundle\Form\ExtensibleEntityType;
    use Alsatian\FormBundle\Form\ExtensibleDocumentType;
    
    // Without route
    $builder->add('extensible_choice', ExtensibleChoiceType::class);
    $builder->add('extensible_entity', ExtensibleEntityType::class,array('class'=>'AppBundle:Article','choice_label'=>'name'));
    $builder->add('extensible_document', ExtensibleDocumentType::class,array('class'=>'AppBundle:Article','choice_label'=>'name'));

    // With route (generate the route defined as 'route' option and renders it as 'data-ajax-url' html attribute)
    $builder->add('extensible_choice', ExtensibleChoiceType::class,array('route'=>'ajax_choices'));
    $builder->add('extensible_entity', ExtensibleEntityType::class,array('route'=>'ajax_entities','class'=>'AppBundle:Article','choice_label'=>'name'));
    $builder->add('extensible_document', ExtensibleDocumentType::class,array('route'=>'ajax_documents','class'=>'AppBundle:Article','choice_label'=>'name'));

This will render HTML like :

<!-- if %alsatian_form.extensible_choice.attr_class% = 'select2' -->
<select data-ajax--url="%your_route%" class="select2">
</select>

The aim of this bundle is only to do the server side work (allowing "extensible" choices). You have to write your own Javescript adapters to get it work with Select2.

As example, how I use it :

$(document).ready(function(){
	$('.select2').each(function(){
		var configs={
		        allowClear: true,
		        width:'resolve',
			ajax:{
				data: function (params) {return {q: params.term};},
				dataType:'json',delay: 250,
				processResults: function (data) {
					var dataresults = [];
					$.each(data, function(key, val){
						dataresults.push({id: val[0], text: val[1]});
					});
					return { results: dataresults };
				}
			};
		};

		$(this).select2(configs);
	});
});
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].