Commit 654dbbb2 by Qiang Xue

Fixes #6678: `yii\behaviors\SluggableBehavior` will generate a new slug only…

Fixes #6678: `yii\behaviors\SluggableBehavior` will generate a new slug only when the slug attribute is empty or the source attribute is changed
parent b5e5b029
...@@ -16,6 +16,7 @@ Yii Framework 2 Change Log ...@@ -16,6 +16,7 @@ Yii Framework 2 Change Log
- Enh #6618: Added Model::addErrors() (slavcodev, pana1990) - Enh #6618: Added Model::addErrors() (slavcodev, pana1990)
- Chg #6427: In case of invalid route web application now throws exception with "Page not found" instead of "Invalid Route" (cebe, samdark) - Chg #6427: In case of invalid route web application now throws exception with "Page not found" instead of "Invalid Route" (cebe, samdark)
- Chg #6641: removed zero padding from ETag strings (DaSourcerer) - Chg #6641: removed zero padding from ETag strings (DaSourcerer)
- Chg #6678: `yii\behaviors\SluggableBehavior` will generate a new slug only when the slug attribute is empty or the source attribute is changed (qiangxue)
2.0.1 December 07, 2014 2.0.1 December 07, 2014
----------------------- -----------------------
......
...@@ -137,7 +137,7 @@ class SluggableBehavior extends AttributeBehavior ...@@ -137,7 +137,7 @@ class SluggableBehavior extends AttributeBehavior
$attributes = (array) $this->attribute; $attributes = (array) $this->attribute;
/* @var $owner BaseActiveRecord */ /* @var $owner BaseActiveRecord */
$owner = $this->owner; $owner = $this->owner;
if (!$owner->getIsNewRecord() && !empty($owner->{$this->slugAttribute})) { if (!empty($owner->{$this->slugAttribute})) {
$isNewSlug = false; $isNewSlug = false;
if (!$this->immutable) { if (!$this->immutable) {
foreach ($attributes as $attribute) { foreach ($attributes as $attribute) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment