Download the PHP package errohitsinghal/yii2-tom-select without Composer

On this page you can find all versions of the php package errohitsinghal/yii2-tom-select. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii2-tom-select

Yii2 Tom Select Widget

Latest Stable Version Total Downloads License Buy Me A Coffee

A Yii2 widget for Tom Select - a dynamic, framework agnostic, and lightweight (~16kb gzipped) <select> UI control with autocomplete and native-feeling keyboard navigation.

Features

Requirements

Installation

Install via Composer:

Quick Start

Basic Select

Without Model

Multi-Select

Configuration Options

Widget Properties

Property Type Default Description
type string 'select' Input type: 'select' or 'text'
items array [] Option items for select element
multiple bool false Allow multiple selections
placeholder string null Placeholder text
create bool/callable false Allow creating new items
maxItems int/null 1 Maximum items (null for unlimited)
maxOptions int/null 50 Maximum options in dropdown
plugins array [] Tom Select plugins to enable
clientOptions array [] Tom Select configuration options
clientEvents array [] Event handlers
useBaseAsset bool false Use base asset (without plugins)
hideSelected bool null Hide selected items from dropdown
closeAfterSelect bool null Close dropdown after selection
allowEmptyOption bool false Allow empty option
searchField string/array null Fields to search in
sortField string/array null Fields to sort by
valueField string 'value' Property to use as value
labelField string 'text' Property to use as label
diacritics bool true Enable diacritics support
loadThrottle int 300 Load throttle in milliseconds
preload bool/string false Preload options (true, false, or 'focus')
renderOption JsExpression null Custom option render function
renderItem JsExpression null Custom item render function
load JsExpression null Remote data loading function
variableName string null JS variable name for instance

Available Plugins

Tom Select comes with many built-in plugins:

Plugin Description
caret_position Use ← and → arrow keys to move between items
change_listener Update when underlying input changes
checkbox_options Display checkboxes in dropdown
clear_button Add button to clear all selections
drag_drop Allow drag-n-drop sorting of items
dropdown_header Add header to dropdown
dropdown_input Move input to dropdown
input_autogrow Auto-grow input width as user types
no_active_items Disable selecting items
no_backspace_delete Prevent backspace deletion
optgroup_columns Display optgroups as columns
remove_button Add remove button to each item
restore_on_backspace Restore deleted items on backspace
virtual_scroll Virtual scrolling for large lists

Usage with ActiveForm

The widget integrates seamlessly with Yii2's ActiveForm. You have two options:

Option 1: Using the Widget Directly

Option 2: Using the ActiveField Extension

For a cleaner syntax, use the custom ActiveField class:

ActiveField Helper Methods

Method Description
tomSelect($items, $options) Basic Tom Select field
tomSelectTags($options) Pre-configured tagging field with remove buttons
tomSelectAjax($url, $options) Pre-configured AJAX loading field

Complete Form Example

Form Validation Styling

Tom Select automatically integrates with Bootstrap 5 validation states. When a field has validation errors, the Tom Select control will display with the appropriate error styling.

Usage Examples

With Option Groups

Tagging (Create New Items)

With Plugins and Options

AJAX Remote Data Loading

With Custom Rendering

Event Handling

Virtual Scroll for Large Datasets

Using HTML Options

Dependent/Chained Dropdowns

Pre-populating with Initial Options (AJAX)

API Methods

After initialization, you can access the Tom Select instance through the variable name:

Using Base Asset (Smaller Footprint)

If you don't need all plugins, use the base asset:

Client Options Reference

All Tom Select options are supported via the clientOptions property. Common options include:

Option Type Default Description
options array [] Initial options list
items array [] Initial selected values
create bool/function false Allow creating new items
createOnBlur bool false Create item when leaving field
createFilter RegExp/string/function null Filter for new items
delimiter string ',' Delimiter for multiple values
highlight bool true Highlight matches
persist bool true Persist created items
openOnFocus bool true Open dropdown on focus
maxOptions int 50 Max options to display
maxItems int null Max items to select
hideSelected bool null Hide selected from dropdown
closeAfterSelect bool undefined Close after selection
allowEmptyOption bool false Allow empty option
loadThrottle int 300 Throttle for load requests
loadingClass string 'loading' Loading state CSS class
placeholder string undefined Placeholder text
preload bool/string false Preload options
dropdownParent string null Dropdown container
addPrecedence bool false "Add..." is default selection
selectOnTab bool false Select with tab key
diacritics bool true International character support
duplicates bool false Allow duplicate selections

Events Reference

Event Arguments Description
initialize - Control initialized
change value Value changed
focus - Control focused
blur - Control blurred
item_add value, item Item added
item_remove value, item Item removed
item_select item Item selected
clear - Selection cleared
option_add value, data Option added
option_remove value Option removed
option_clear - All options cleared
optgroup_add id, data Option group added
optgroup_remove id Option group removed
optgroup_clear - All option groups cleared
dropdown_open dropdown Dropdown opened
dropdown_close dropdown Dropdown closed
type str User typing
load data Options loaded
destroy - Control destroyed

Styling

The widget uses Bootstrap 5 themed CSS by default. You can customize the appearance:

Override CSS Variables

Custom CSS Classes

Troubleshooting

Widget not initializing

Make sure jQuery is loaded if you're using it elsewhere. Tom Select doesn't require jQuery but may conflict if jQuery plugins modify the DOM.

Options not showing

Check that your items array is properly formatted:

AJAX not working

Ensure your endpoint returns JSON in the expected format:

And configure valueField and labelField to match your data structure.

Multiple selection not working

Make sure multiple is set to true:

Support

If you find this package helpful, consider buying me a coffee! ☕

Buy Me A Coffee

License

This package is open-sourced software licensed under the MIT License.

Credits

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Changelog

1.0.0


All versions of yii2-tom-select with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
yiisoft/yii2 Version ~2.0.45
yiisoft/yii2-bootstrap5 Version ~2.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package errohitsinghal/yii2-tom-select contains the following files

Loading the files please wait ...