-
Notifications
You must be signed in to change notification settings - Fork 111
Newest Dev version: Array fields cause Error in Form #802
Copy link
Copy link
Closed
Labels
Description
Hi there,
the latest merged pr #784 causes some fields that are defined as array to crash the form. In my example the field was defined like this in model:
$this->addFields([
['created_records', 'type' => 'array', 'serialize' => 'json', 'default' => []],
That caused an Error in Form linr 455:
Error: Call to a member function refModel() on null
Reading the code:
if ($f->type === 'array') {
$limit = ($f->reference instanceof ContainsMany) ? 0 : 1;
$model = $f->reference->refModel();
$fallback_seed = ['MultiLine', 'model' => $model, 'rowLimit' => $limit, 'caption' => $model->getModelCaption()];
}
So its assumed that whenever a field is defined as array, it has a reference set, which, of course, must not neccessarily be.
I fixed my issue and set the field to system=true so it wont appear in Form at all, but thats only a workaround.
Reactions are currently unavailable