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.
 
 
 
 
 

57 lines
1.4 KiB

<?php
namespace core\forms;
use core\components\LanguageDynamicModel;
use core\entities\Meta;
use Yii;
class MetaForm extends LanguageDynamicModel
{
public $title;
public $description;
public $keywords;
private $_meta;
public function __construct(Meta $meta = null, $config = [])
{
if ($meta) {
$this->title = $meta->title;
$this->description = $meta->description;
$this->keywords = $meta->keywords;
$this->_meta = $meta;
}
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() {
return array_merge(
parent::attributeLabels(),
[
'title' => Yii::t('main', 'Title'),
'description' => Yii::t('main', 'Description'),
'keywords' => Yii::t('main', 'Keywords'),
]
);
}
}