SluggableBehavior with title if Slug field is empty


I want make slug with title if Slug field is empty.

I can’t found the way resolve problem.


If create or update a post. If I type Title but I don’t enter any words in field slug. When I submit to save post, slug will make with Title field

Help me solution

The whole point of the sluggable behavior is that it generates the slug automatically - usually from the title.

How did you set it up?

My config:

public function behaviors()


		return [



				'class' => SluggableBehavior::className(),

				'attribute' => 'title',

				'immutable' => true




I understand, but I want User can manualy make slug.

Then do not use the behavior but use the code instead to check if the user provided a valid slug, and if not then generate one. Or modify the invalid slug given so that it becomes valid. :)

I can make a function check it in controller before save. But I don’t know Sluggable Behavior supported or not.