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
- 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 #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
-----------------------
......
......@@ -137,7 +137,7 @@ class SluggableBehavior extends AttributeBehavior
$attributes = (array) $this->attribute;
/* @var $owner BaseActiveRecord */
$owner = $this->owner;
if (!$owner->getIsNewRecord() && !empty($owner->{$this->slugAttribute})) {
if (!empty($owner->{$this->slugAttribute})) {
$isNewSlug = false;
if (!$this->immutable) {
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