|
|
@ -42,12 +42,11 @@ class PageForm extends CompositeForm |
|
|
|
public function rules(): array |
|
|
|
public function rules(): array |
|
|
|
{ |
|
|
|
{ |
|
|
|
return [ |
|
|
|
return [ |
|
|
|
[['title', 'slug'], 'required'], |
|
|
|
[['title'], 'required'], |
|
|
|
[['parentId'], 'integer'], |
|
|
|
[['parentId'], 'integer'], |
|
|
|
[['title', 'slug'], 'string', 'max' => 255], |
|
|
|
[['title', 'slug'], 'string', 'max' => 255], |
|
|
|
[['content'], 'string'], |
|
|
|
[['content'], 'string'], |
|
|
|
['slug', SlugValidator::class], |
|
|
|
['slug', SlugValidator::class], |
|
|
|
//[['slug'], 'unique', 'targetClass' => Page::class, 'filter' => $this->_page ? ['<>', 'id', $this->_page->id] : null] |
|
|
|
|
|
|
|
[['slug'], 'unique', 'targetClass' => Page::class, 'filter' => function (ActiveQuery $query) { |
|
|
|
[['slug'], 'unique', 'targetClass' => Page::class, 'filter' => function (ActiveQuery $query) { |
|
|
|
if ($this->type != Page::TYPE_PUBLIC) { |
|
|
|
if ($this->type != Page::TYPE_PUBLIC) { |
|
|
|
$query->andWhere($this->type . '=' . Page::TYPE_PUBLIC); |
|
|
|
$query->andWhere($this->type . '=' . Page::TYPE_PUBLIC); |
|
|
@ -72,6 +71,12 @@ class PageForm extends CompositeForm |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function attributeHints() { |
|
|
|
|
|
|
|
return [ |
|
|
|
|
|
|
|
'slug' => Yii::t('page', 'SEO link will be generated automatically if not specified'), |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function parentsList(): array |
|
|
|
public function parentsList(): array |
|
|
|
{ |
|
|
|
{ |
|
|
|
return ArrayHelper::map(Page::find()->andWhere(['tree' => 1])->orderBy('lft')->asArray()->all(), 'id', function (array $page) { |
|
|
|
return ArrayHelper::map(Page::find()->andWhere(['tree' => 1])->orderBy('lft')->asArray()->all(), 'id', function (array $page) { |
|
|
|