yiisoft/yii2-jquery jQuery integration layer for Yii2 asset bundles, client validation scripts, and widget client scripts.

Yii Framework

jQuery Integration Extension for Yii2

  1. Installation
  2. Usage
  3. Overriding a single validator
  4. Quality code
  5. Documentation
  6. Support the project
  7. Follow updates
  8. License

This extension provides the optional jQuery integration layer for Yii Framework 2.0 applications. It supplies jQuery-backed asset bundles, client-side validation scripts, and widget client scripts for every core validator, grid component, and widget that supports the client-script strategy pattern.

Latest Stable Version Total Downloads build codecov Static Analysis

Installation

[!IMPORTANT]

The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist yiisoft/yii2-jquery:~1.0.0

or add

"yiisoft/yii2-jquery": "~1.0.0"

to the require section of your composer.json file.

Usage

Once the extension is installed, register the bootstrap class in your application configuration:

return [
    'bootstrap' => [
        \yii\jquery\Bootstrap::class,
    ],
    // ...
];

The Bootstrap class configures the DI container with jQuery-based $clientScript defaults for every core validator, grid component, and widget that supports the client-script strategy pattern. No further configuration is required.

Overriding a single validator

You can override the client-script implementation on a per-rule basis by passing the clientScript key in the rule definition:

public function rules(): array
{
    return [
        [
            'email',
            'required',
            'clientScript' => ['class' => MyCustomRequiredClientScript::class],
        ],
    ];
}

Quality code

PHPStan Level StyleCI

Documentation

Support the project

Open Collective

Follow updates

Official website Follow on X Telegram Slack

License

License

0 0
1
1 824
Yii Version: 22.0
License: BSD-3-Clause
Category: User Interface
Developed by: The Yii Team
Created: Apr 6, 2018
Packagist Profile
Github Repository

Related Extensions