Download the PHP package abolotin/yii2-unique-id without Composer
On this page you can find all versions of the php package abolotin/yii2-unique-id. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii2-unique-id
Unique widget's IDs generator
Generating unique identificator for any purposes. Typically used by Yii-widgets ("id"-attribute of HTML elements).
Standard Yii2 generator use prefix "w" and simple counter of generated IDs. It's enougth while non-AJAX requests used. But if you're want to load some page content via AJAX-request, you're can obtain HTML-elements with same IDs ("w1", for example). So, some scripts, based on element's ID, will work unexpectedly. Such behaviour may be bypassed by specifying ID manually in code. Another way is setting up Widget::$autoIdPrefix.
Installation
Using Composer
You can use the composer package manager to install. Either run:
$ php composer.phar require abolotin/yii2-unique-id
or add:
"abolotin/yii2-unique-id": ""
to your composer.json file
Manual Install
You can also manually install the component easily to your project. Just download the source ZIP or TAR ball
Usage
Using in manual mode
Just call \abolotin\yii2\UniqueId::getId(). It's returns unique value, which can be assigned to "id" attribute of HTML-element.
Using in automatic mode
You're can to setup automatic generation of IDs by any \yii\base\Widget based objects. Just add '\abolotin\yii2\UniqueId' string to 'bootstrap' array of applications configuraion:
or using component's mode:
In last case it's can be also configured.
Configuration
Component allows next configuration options:
widgetPrefix - string. First prefix, used by widget generator. Default value: 'w'.
pjaxPrefix - string. First prefix, used by Pjax widget generator. Default value: 'p'.
autoIdPrefix - string. Second prefix, used by generator. If unspecified, will be generated automatically.
counter - integer. Inner generated IDs counter. Default value: 0.
suffix - string. Suffix of inner generated ID. Default value: 't'.