Commit 58516ae8 by Qiang Xue

Fixes #6434: Added `yii\behaviors\SluggableBehavior::immutable` to support…

Fixes #6434: Added `yii\behaviors\SluggableBehavior::immutable` to support keeping the generated slug unchanged
parent 4dd15a66
......@@ -5,9 +5,9 @@ Yii Framework 2 Change Log
-----------------------
- Bug #6404: advanced application template `Alert` widget was generating duplicate IDs in case of multiple flashes (SDKiller)
- Enh #6434: Added `yii\behaviors\SluggableBehavior::immutable` to support keeping the generated slug unchanged (trntv)
- Enh #6467: `ActiveForm` will scroll to the nearest visible element when the first error input is hidden (newartix)
2.0.1 December 07, 2014
-----------------------
......
......@@ -77,8 +77,9 @@ class SluggableBehavior extends AttributeBehavior
*/
public $value;
/**
* @var boolean whether to generate new slug if it already filled but attribute was changed.
* If enabled behavior will not generate new slug after attributes in model was changed.
* @var boolean whether to generate a new slug if it has already been generated before.
* If true, the behavior will not generate a new slug even if [[attribute]] is changed.
* @since 2.0.2
*/
public $immutable = false;
/**
......@@ -138,7 +139,7 @@ class SluggableBehavior extends AttributeBehavior
$owner = $this->owner;
if (!$owner->getIsNewRecord() && !empty($owner->{$this->slugAttribute})) {
$isNewSlug = false;
if(!$this->immutable){
if (!$this->immutable) {
foreach ($attributes as $attribute) {
if ($owner->isAttributeChanged($attribute)) {
$isNewSlug = true;
......
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