2017 © Pedro Peláez
 

library yii2-unique-id

Generating unique identificator for any purposes. Typically used by Yii-widgets ("id"-attribute of HTML elements).

image

abolotin/yii2-unique-id

Generating unique identificator for any purposes. Typically used by Yii-widgets ("id"-attribute of HTML elements).

  • Thursday, May 10, 2018
  • by abolotin
  • Repository
  • 0 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 40 % Grown

The README.md

Unique widget's IDs generator

Generating unique identificator for any purposes. Typically used by Yii-widgets ("id"-attribute of HTML elements)., (*1)

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., (*2)

Installation

Using Composer

You can use the composer package manager to install. Either run:, (*3)

$ php composer.phar require abolotin/yii2-unique-id, (*4)

or add:, (*5)

"abolotin/yii2-unique-id": "", (*6)

to your composer.json file, (*7)

Manual Install

You can also manually install the component easily to your project. Just download the source ZIP or TAR ball, (*8)

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., (*9)

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:, (*10)

return [
   ...
   'bootstrap' => [
       '\\abolotin\\yii2\\UniqueId',
       ...
   ]
];

or using component's mode:, (*11)

return [
   ...
   'components' => [
       'uniqueId' => [
           'class' => '\\abolotin\\yii2\\UniqueId',
           ...
       ],
       ...
   ],
   'bootstrap' => [
       'uniqueId',
       ...
   ]
];

In last case it's can be also configured., (*12)

Configuration

Component allows next configuration options:, (*13)

widgetPrefix - string. First prefix, used by widget generator. Default value: 'w'., (*14)

pjaxPrefix - string. First prefix, used by Pjax widget generator. Default value: 'p'., (*15)

autoIdPrefix - string. Second prefix, used by generator. If unspecified, will be generated automatically., (*16)

counter - integer. Inner generated IDs counter. Default value: 0., (*17)

suffix - string. Suffix of inner generated ID. Default value: 't'., (*18)

The Versions

10/05 2018

dev-master

9999999-dev

Generating unique identificator for any purposes. Typically used by Yii-widgets ("id"-attribute of HTML elements).

  Sources   Download

BSD-3-Clause

The Requires

 

by Anton Bolotin

php yii2

10/05 2018

1.0.2

1.0.2.0

Generating unique identificator for any purposes. Typically used by Yii-widgets ("id"-attribute of HTML elements).

  Sources   Download

BSD-3-Clause

The Requires

 

by Anton Bolotin

php yii2

10/05 2018

dev-abolotin-patch-3

dev-abolotin-patch-3

Generating unique identificator for any purposes. Typically used by Yii-widgets ("id"-attribute of HTML elements).

  Sources   Download

BSD-3-Clause

The Requires

 

by Anton Bolotin

php yii2

10/05 2018

dev-abolotin-patch-2

dev-abolotin-patch-2

Generating unique identificator for any purposes. Typically used by Yii-widgets ("id"-attribute of HTML elements).

  Sources   Download

BSD-3-Clause

The Requires

 

by Anton Bolotin

php yii2

08/05 2018

1.0.1

1.0.1.0

Generating unique identificator for any purposes. Typically used by Yii-widgets ("id"-attribute of HTML elements).

  Sources   Download

BSD-3-Clause

The Requires

 

by Anton Bolotin

php yii2

08/05 2018

dev-abolotin-patch-1

dev-abolotin-patch-1

Generating unique identificator for any purposes. Typically used by Yii-widgets ("id"-attribute of HTML elements).

  Sources   Download

BSD-3-Clause

The Requires

 

by Anton Bolotin

php yii2

08/05 2018

1.0.0

1.0.0.0

Generating unique identificator for any purposes. Typically used by Yii-widgets ("id"-attribute of HTML elements).

  Sources   Download

BSD-3-Clause

The Requires

 

by Anton Bolotin

php yii2