You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

55 lines
1.4 KiB

<?php
namespace core\forms;
use core\components\LanguageDynamicModel;
use core\entities\Meta;
use Yii;
class MetaForm extends LanguageDynamicModel
{
public ?string $title = null;
public ?string $description = null;
public ?string $keywords = null;
public function __construct(Meta $meta = null, $config = [])
{
if ($meta) {
$this->title = $meta->title;
$this->description = $meta->description;
$this->keywords = $meta->keywords;
}
parent::__construct($config);
// fill translate values
/*if ($meta) {
foreach ( $meta->translations as $translate ) {
$this->{'title' . '_' . $translate->language} = $translate->title;
$this->{'description' . '_' . $translate->language} = $translate->description;
$this->{'keywords' . '_' . $translate->language} = $translate->keywords;
};
};*/
}
public function rules(): array
{
return array_merge(
parent::rules(),
[
[['title'], 'string', 'max' => 255],
[['description', 'keywords'], 'string'],
]
);
}
public function attributeLabels(): array
{
return array_merge(
parent::attributeLabels(),
[
'title' => Yii::t('main', 'Title'),
'description' => Yii::t('main', 'Description'),
'keywords' => Yii::t('main', 'Keywords'),
]
);
}
}