All Projects → bymayo → craft-select2

bymayo / craft-select2

Licence: MIT license
Filter / search a <select> using the popular Select2 fieldtype for Craft CMS

Programming Languages

PHP
23972 projects - #3 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to craft-select2

laravel-simple-select
Laravel Simple Select inputs component for Blade and Livewire.
Stars: ✭ 59 (+227.78%)
Mutual labels:  select, select2, select-multiple
Choices
A vanilla JS customisable select box/text input plugin ⚡️
Stars: ✭ 4,505 (+24927.78%)
Mutual labels:  select, select2, select-multiple
VzAddress-Craft
Address fieldtype for the Craft CMS
Stars: ✭ 30 (+66.67%)
Mutual labels:  craftcms, craftcms-plugin, fieldtype
selectr
✅ The coolest jQuery select plugin you've never seen
Stars: ✭ 19 (+5.56%)
Mutual labels:  select, select-multiple
Craft-TemplateSelect
Allows you to select templates for an entry in Craft CMS
Stars: ✭ 30 (+66.67%)
Mutual labels:  craftcms, craftcms-plugin
craft-commerce-widgets
Insightful widgets for Craft CMS Commerce stores
Stars: ✭ 33 (+83.33%)
Mutual labels:  craftcms, craftcms-plugin
select2-to-tree
Select2-to-Tree extends Select2 to support arbitrary level of nesting...
Stars: ✭ 71 (+294.44%)
Mutual labels:  select, select2
django-select2
This is a Django integration for Select2
Stars: ✭ 73 (+305.56%)
Mutual labels:  select, select2
Form-Builder
Craft CMS plugin that lets you create and manage forms for your front-end.
Stars: ✭ 16 (-11.11%)
Mutual labels:  craftcms, craftcms-plugin
Stf Vue Select
stf vue select - most flexible and customized select
Stars: ✭ 61 (+238.89%)
Mutual labels:  select, select2
craft3-collections
Clean up those complex templates with Laravel Collections
Stars: ✭ 24 (+33.33%)
Mutual labels:  craftcms, craftcms-plugin
craft-entriessubset
Craft field type plugin that extends the core Entries field type to give extra settings
Stars: ✭ 27 (+50%)
Mutual labels:  craftcms, craftcms-plugin
Craft-UserCreator
Allow you to generate users en masse, simply.
Stars: ✭ 16 (-11.11%)
Mutual labels:  craftcms, craftcms-plugin
smartdown.craft-plugin
Bringing the unbridled joy of Markdown Extra and Smartypants to your Craft websites.
Stars: ✭ 26 (+44.44%)
Mutual labels:  craftcms, craftcms-plugin
craft3-codemirror
Add the awesome in-browser code editor CodeMirror as a field type.
Stars: ✭ 17 (-5.56%)
Mutual labels:  craftcms, fieldtype
Craft-Embedly
Embed.ly plugin for Craft CMS
Stars: ✭ 21 (+16.67%)
Mutual labels:  craftcms, craftcms-plugin
events
Craft CMS Plugin for events management and ticketing.
Stars: ✭ 19 (+5.56%)
Mutual labels:  craftcms, craftcms-plugin
Stamp-Craft
Plugin for adding timestamp to filenames.
Stars: ✭ 28 (+55.56%)
Mutual labels:  craftcms, craftcms-plugin
Craft-CacheWarmer
Warm up your cache with a single request.
Stars: ✭ 38 (+111.11%)
Mutual labels:  craftcms, craftcms-plugin
Ng Select
Select component for angular
Stars: ✭ 291 (+1516.67%)
Mutual labels:  select, select2

⚡️Looking for Craft CMS 3 Support? Lucky for you, I'm working on it 🚧

Select2

Select2 is a Craft CMS fieldtype that uses the popular jQuery plugin - Select2 (https://select2.github.io). It extends the functionality of a <select> field, allowing users to search/filter down their options.

This fieldtype also comes with predefined JSON lists to take the chore out of creating fields such as Country, State or Social Network <select> fields.

You can also specify your own JSON files, which means if you require the same field inside a Matrix or a Supertable for example, you don't have to create all them options again!

Features

  • Extends <select> field, allowing to search and filter <option>'s
  • Allow multiple option selections
  • Limit the amount of options that can be selected
  • Placeholder
  • Predefined JSON lists
  • Add custom JSON files

Install

  • Add the select2 directory into your craft/plugins directory.
  • Navigate to Settings -> Plugins and click the "Install" button.

Predefined JSON Lists

  • Countries United Kingdom
  • Countries (2 Digit ISO) GB
  • Countries (3 Digit ISO) GBR
  • Currency (3 Digit ISO) EUR
  • Languages (2 Digit ISO) EN
  • Social Networks Facebook
  • UK Counties Greater Manchester
  • US States NY

(If you have a list idea that you'd like included, please start a Github Issue)

Using custom JSON files

Select2 gives you the ability to add custom JSON files to the fields.

Setup

To use custom JSON files, create a select2 folder inside your craft/templates folder.

This folder name can be changed by defining the the config settings below in your craft/config/general.php file.

'select2' => [
   'jsonFolder' => 'jsonFolder'
]

By placing your JSON files inside this folder, they will automatically appear in the JSON list when setting up the field.

JSON Format

To make sure the data loads in to the field correctly, the JSON files you create need to have a label and a value. For example -

[
    {
        "label": "Hamburger",
        "value": "hamburger"
    },
    {
        "label": "Hot Dog",
        "value": "hotDog"
    },
    {
        "label": "Chicken Wings",
        "value": "chickenWings"
    }
]

The content inside label and value can be formatted however you wish (camelCase, UPPERCASE etc).

Field Settings

Setting Description
List Allows you to choose a predefined list, or select JSON to specify your own list
JSON Pulls through all JSON files stored in the `select2` folder (See Using custom JSON files)
Multiple If you want to allow more than 1 option to be selected, turn this switch on
Limit If Multiple is set, then you can specify the maximum amount of options that can be selected
Placeholder A placeholder that appears in the Select2 field, e.g. 'Please Select a Country'

Templating

Select2 outputs either a string or array depending on if you have checked the multiple option when setting up the field. The TWIG code for this is very basic and no different to looping through a Matrix etc. For example, if your field is called profileCountries the template tags would be:

{% for country in entry.profileCountries %}
	{{ country }}
{% endfor %}

Roadmap

  • More predefined JSON lists
  • Template tags to output both label and value
  • Ability to add <optgroup>'s
  • Ability to add more than a label and value
  • Adjust CSS (Possibly port it to SASS) to make the field work better with Craft CMS styling

Credits

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