Commit 7a81fff9 by Alexander Kochetov

SluggableBehavior updated

parent 22b04c5c
......@@ -20,11 +20,9 @@ use yii\helpers\Inflector;
class SluggableBehavior extends AttributeBehavior
{
/**
* @inheritdoc
* @var string
*/
public $attributes = [
BaseActiveRecord::EVENT_BEFORE_VALIDATE => 'slug',
];
public $slugAttribute = 'slug';
/**
* @var string
*/
......@@ -35,6 +33,12 @@ class SluggableBehavior extends AttributeBehavior
*/
public function init()
{
parent::init();
if (empty($this->attributes)) {
$this->attributes = [BaseActiveRecord::EVENT_BEFORE_VALIDATE => $this->slugAttribute];
}
if ($this->attribute === null && $this->value === null) {
throw new InvalidConfigException('Either "attribute" or "value" properties must be specified.');
}
......
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