Skip to content

Newest Dev version: Array fields cause Error in Form #802

@PhilippGrashoff

Description

@PhilippGrashoff

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.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions