Skip to content

Commit

Permalink
Fixed published_at save bug
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodeholic authored Feb 22, 2018
1 parent ccf9a9f commit c3aaa8a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion models/TranslatableModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace centigen\i18ncontent\models;

use centigen\base\helpers\DateHelper;
use centigen\i18ncontent\helpers\Html;
use Yii;
use yii\db\ActiveRecord;
Expand Down Expand Up @@ -55,6 +56,14 @@ public function getActiveTranslation()
*/
public function load($postData, $formName = null)
{
$scope = $formName === null ? $this->formName() : $formName;
$myData = ArrayHelper::getValue($postData, $scope);

if (isset($myData['published_at']) && $myData['published_at']) {
$myData['published_at'] = DateHelper::fromFormatIntoMysql(DateHelper::$yiiFormatToPhpMapping[\Yii::$app->formatter->datetimeFormat], $myData['published_at']);
$myData['published_at'] = DateHelper::fromMySqlIntoTimestamp($myData['published_at']);
$postData[$scope] = $myData;
}
if (!parent::load($postData, $formName)) {
return false;
}
Expand Down Expand Up @@ -141,4 +150,4 @@ public function findTranslationByLocale($locale)

return new static::$translateModel();
}
}
}

0 comments on commit c3aaa8a

Please sign in to comment.