From e8aa60e41174b94add149d1c533fa19cc17d2bda Mon Sep 17 00:00:00 2001 From: SilverFire - Dmitry Naumenko Date: Sun, 6 Dec 2015 21:50:33 +0200 Subject: [PATCH] Merge branch 'pjax' of https://github.com/Alex-Code/yii2 into Alex-Code-pjax --- framework/CHANGELOG.md | 7 ++++--- framework/widgets/Pjax.php | 15 ++++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 2815929d31..c9dad00bdc 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -43,10 +43,11 @@ Yii Framework 2 Change Log - Bug #10302: Fixed JS function `yii.getQueryParams`, which parsed array variables incorrectly (servocoder, silverfire) - Bug: Fixed generation of canonical URLs for `ViewAction` pages (samdark) - Bug: Fixed `mb_*` functions calls to use `UTF-8` or `Yii::$app->charset` (silverfire) -- Enh #3506: Added `\yii\validators\IpValidator` to perform validation of IP addresses and subnets (SilverFire, samdark) -- Enh #5146: Added `\yii\i18n\Formatter::asDuration()` method (nineinchnick, SilverFire) +- Enh #3506: Added `yii\validators\IpValidator` to perform validation of IP addresses and subnets (SilverFire, samdark) +- Enh #4104: Added `yii\filters\auth\AuthMethod::optional` for optional authentification in all child classes (SilverFire) +- Enh #5146: Added `yii\i18n\Formatter::asDuration()` method (nineinchnick, SilverFire) +- Enh #5902: `yii\widgets\Pjax::options` now support special option `tag` to specify tag of container (Alex-Code) - Enh #7341: Client validation now skips disabled inputs (SamMousa) -- Enh #4104: Added `yii\filters\auth\AuthMetod::optional` for optional authentification in all child classes (SilverFire) - Enh #7566: Improved `\yii\validators\CompareValidator` default messages (slinstj) - Enh #7581: Added ability to specify range using anonymous function in `RangeValidator` (RomeroMsk) - Enh #8284: Added `\yii\captcha\CaptchaAction::$imageLibrary` property allowing to set image rendering library (AnatolyRugalev) diff --git a/framework/widgets/Pjax.php b/framework/widgets/Pjax.php index c271ffcab4..a69c68f54a 100644 --- a/framework/widgets/Pjax.php +++ b/framework/widgets/Pjax.php @@ -9,6 +9,7 @@ namespace yii\widgets; use Yii; use yii\base\Widget; +use yii\helpers\ArrayHelper; use yii\helpers\Html; use yii\helpers\Json; use yii\web\Response; @@ -44,7 +45,10 @@ use yii\web\Response; class Pjax extends Widget { /** - * @var array the HTML attributes for the widget container tag. + * @var array the HTML attributes for the widget container tag. The following special options are recognized: + * + * - `tag`: string, the tag name for the container. Defaults to `div` + * * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. */ public $options = []; @@ -87,7 +91,6 @@ class Pjax extends Widget */ public $clientOptions; - /** * @inheritdoc */ @@ -109,13 +112,15 @@ class Pjax extends Widget echo Html::tag('title', Html::encode($view->title)); } } else { - echo Html::beginTag('div', array_merge([ + $options = $this->options; + $tag = ArrayHelper::remove($options, 'tag', 'div'); + echo Html::beginTag($tag, array_merge([ 'data-pjax-container' => '', 'data-pjax-push-state' => $this->enablePushState, 'data-pjax-replace-state' => $this->enableReplaceState, 'data-pjax-timeout' => $this->timeout, 'data-pjax-scrollto' => $this->scrollTo, - ], $this->options)); + ], $options)); } } @@ -125,7 +130,7 @@ class Pjax extends Widget public function run() { if (!$this->requiresPjax()) { - echo Html::endTag('div'); + echo Html::endTag(ArrayHelper::remove($this->options, 'tag', 'div')); $this->registerClientScript(); return;