diff --git a/helpers/Html.php b/helpers/Html.php index e145ed8..1008be6 100644 --- a/helpers/Html.php +++ b/helpers/Html.php @@ -55,6 +55,11 @@ public static function decodeMediaItemUrls($text) return str_replace($module->mediaUrlReplacement, $module->mediaUrlPrefix, $text); } + /** + * @param $model + * @param bool $disabled + * @return string + */ public static function asFab($model, $disabled = false){ $formatter = new Formatter(); return $formatter->asToggle($model->status, $disabled); diff --git a/models/Article.php b/models/Article.php index c57aa2c..8d1528a 100644 --- a/models/Article.php +++ b/models/Article.php @@ -129,12 +129,11 @@ public function rules() [['category_id'], 'required'], [['slug'], 'unique'], [['published_at'], 'default', 'value' => time()], - [['published_at'], 'filter', 'filter' => 'strtotime'], [['category_id'], 'exist', 'targetClass' => ArticleCategory::className(), 'targetAttribute' => 'id'], [['author_id', 'updater_id', 'position', 'status'], 'integer'], [['slug', 'thumbnail_base_url', 'thumbnail_path', 'url'], 'string', 'max' => 2024], [['view'], 'string', 'max' => 255], - [['attachments', 'thumbnail'], 'safe'] + [['attachments', 'thumbnail', 'published_at'], 'safe'] ]; } diff --git a/models/TranslatableModel.php b/models/TranslatableModel.php index fccbbe2..db26753 100644 --- a/models/TranslatableModel.php +++ b/models/TranslatableModel.php @@ -59,6 +59,10 @@ public function load($postData, $formName = null) return false; } + if($this->hasAttribute('published_at')){ + $this->published_at = $this->published_at ? strtotime($this->published_at) : time(); + } + $className = \yii\helpers\StringHelper::basename(static::$translateModel); $translations = ArrayHelper::getValue($postData, $className); $this->newTranslations = [];