Fix setting form meta when form has no fields

This commit is contained in:
philipp lang 2024-02-22 00:06:16 +01:00
parent 0bc00207b2
commit 60b0052622
1 changed files with 2 additions and 2 deletions

View File

@ -140,8 +140,8 @@ class Form extends Model implements HasMedia
static::saving(function (self $model) {
if (is_null($model->meta)) {
$model->setAttribute('meta', [
'active_columns' => $model->getFields()->take(4)->pluck('key')->toArray(),
'sorting' => [$model->getFields()->first()['key'], 'asc'],
'active_columns' => $model->getFields()->count() ? $model->getFields()->take(4)->pluck('key')->toArray() : null,
'sorting' => $model->getFields()->count() ? [$model->getFields()->first()['key'], 'asc'] : null,
]);
}
});