mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-24 18:51:27 +08:00
Fixes #2380: Added yii\widgets\ActiveForm::enableClientScript to support turning on and off client side script generation
This commit is contained in:
@@ -112,6 +112,7 @@ Yii Framework 2 Change Log
|
|||||||
- Enh #1452: Added `Module::getInstance()` to allow accessing the module instance from anywhere within the module (qiangxue)
|
- Enh #1452: Added `Module::getInstance()` to allow accessing the module instance from anywhere within the module (qiangxue)
|
||||||
- Enh #2264: `CookieCollection::has()` will return false for expired or removed cookies (qiangxue)
|
- Enh #2264: `CookieCollection::has()` will return false for expired or removed cookies (qiangxue)
|
||||||
- Enh #2315: Any operator now could be used with `yii\db\Query::->where()` operand format (samdark)
|
- Enh #2315: Any operator now could be used with `yii\db\Query::->where()` operand format (samdark)
|
||||||
|
- Ehn #2380: Added `yii\widgets\ActiveForm::enableClientScript` to support turning on and off client side script generation (qiangxue)
|
||||||
- Enh #2435: `yii\db\IntegrityException` is now thrown on database integrity errors instead of general `yii\db\Exception` (samdark)
|
- Enh #2435: `yii\db\IntegrityException` is now thrown on database integrity errors instead of general `yii\db\Exception` (samdark)
|
||||||
- Enh #2558: Enhanced support for memcached by adding `yii\caching\MemCache::persistentId` and `yii\caching\MemCache::options` (qiangxue)
|
- Enh #2558: Enhanced support for memcached by adding `yii\caching\MemCache::persistentId` and `yii\caching\MemCache::options` (qiangxue)
|
||||||
- Enh #2837: Error page now shows arguments in stack trace method calls (samdark)
|
- Enh #2837: Error page now shows arguments in stack trace method calls (samdark)
|
||||||
@@ -233,7 +234,6 @@ Yii Framework 2 Change Log
|
|||||||
- `yii\base\Formatter` functionality has been merged into `yii\i18n\Formatter`
|
- `yii\base\Formatter` functionality has been merged into `yii\i18n\Formatter`
|
||||||
- removed the `yii\base\Formatter` class
|
- removed the `yii\base\Formatter` class
|
||||||
- Chg #1551: Refactored DateValidator to support ICU date format and use the format defined in Formatter by default (cebe)
|
- Chg #1551: Refactored DateValidator to support ICU date format and use the format defined in Formatter by default (cebe)
|
||||||
- Chg #2380: `yii\widgets\ActiveForm` will register validation js even if there are not fields inside (qiangxue)
|
|
||||||
- Chg #2898: `yii\console\controllers\AssetController` is now using hashes instead of timestamps (samdark)
|
- Chg #2898: `yii\console\controllers\AssetController` is now using hashes instead of timestamps (samdark)
|
||||||
- Chg #2913: RBAC `DbManager` is now initialized via migration (samdark)
|
- Chg #2913: RBAC `DbManager` is now initialized via migration (samdark)
|
||||||
- Chg #2914: `ActiveForm::fieldConfig` will be merged recursively with the `$options` parameter in `ActiveForm::field()` (qiangxue)
|
- Chg #2914: `ActiveForm::fieldConfig` will be merged recursively with the `$options` parameter in `ActiveForm::field()` (qiangxue)
|
||||||
|
|||||||
@@ -104,6 +104,13 @@ class ActiveForm extends Widget
|
|||||||
* If [[ActiveField::enableAjaxValidation]] is set, its value will take precedence for that input field.
|
* If [[ActiveField::enableAjaxValidation]] is set, its value will take precedence for that input field.
|
||||||
*/
|
*/
|
||||||
public $enableAjaxValidation = false;
|
public $enableAjaxValidation = false;
|
||||||
|
/**
|
||||||
|
* @var boolean whether to hook up yii.activeForm JavaScript plugin.
|
||||||
|
* This property must be set true if you want to support client validation and/or AJAX validation, or if you
|
||||||
|
* want to take advantage of the yii.activeForm plugin. When this is false, the form will not generate
|
||||||
|
* any JavaScript.
|
||||||
|
*/
|
||||||
|
public $enableClientScript = true;
|
||||||
/**
|
/**
|
||||||
* @var array|string the URL for performing AJAX-based validation. This property will be processed by
|
* @var array|string the URL for performing AJAX-based validation. This property will be processed by
|
||||||
* [[Url::to()]]. Please refer to [[Url::to()]] for more details on how to configure this property.
|
* [[Url::to()]]. Please refer to [[Url::to()]] for more details on how to configure this property.
|
||||||
@@ -179,12 +186,14 @@ class ActiveForm extends Widget
|
|||||||
throw new InvalidCallException('Each beginField() should have a matching endField() call.');
|
throw new InvalidCallException('Each beginField() should have a matching endField() call.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $this->options['id'];
|
if ($this->enableClientScript) {
|
||||||
$options = Json::encode($this->getClientOptions());
|
$id = $this->options['id'];
|
||||||
$attributes = Json::encode($this->attributes);
|
$options = Json::encode($this->getClientOptions());
|
||||||
$view = $this->getView();
|
$attributes = Json::encode($this->attributes);
|
||||||
ActiveFormAsset::register($view);
|
$view = $this->getView();
|
||||||
$view->registerJs("jQuery('#$id').yiiActiveForm($attributes, $options);");
|
ActiveFormAsset::register($view);
|
||||||
|
$view->registerJs("jQuery('#$id').yiiActiveForm($attributes, $options);");
|
||||||
|
}
|
||||||
|
|
||||||
echo Html::endForm();
|
echo Html::endForm();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user