Closed mkrecek234 closed 2 years ago
@mkrecek234 please do not add MAJOR
to (every) bug, MAJOR
is something conceptually wrong or with major impact on most users.
Also, please copy/screenshot full backtrace in case you want to refer to it. Refering to a line number without knowing the file is almost useless. The same for the exception message, as the reason might depend on a context which is shown in exceptions params (added by Exception::addMoreInfo()
).
The issue is in line 734, as isEditable is not existing as a property for SqlExpressionField.
There is no isEditable
property in atk4/data. There is only Field::isEditable()
method, which by inheritance available in SqlExpressionField
. Can you please post a minimalistic code to reproduce or is it possible to reproduce it on atk4/ui demos?
Correct - it relates to the missing isEditable() property of SqlExpressionField. In Model::getFields() the following code is not compatible with SqlExpressionField:
($f === 'system' && $field->system)
|| ($f === 'not system' && !$field->system)
|| ($f === 'editable' && $field->isEditable())
|| ($f === 'visible' && $field->isVisible())
) {
As I cannot create minimalistic code on demo today, here already the info to reproduce:
$model->addExpression('expressionfield', ['expr' => "1"]);
In a child model create a hasOne and import that expression:
$childmodel->hasOne('model_id', ['model' => [Model::class]])->addFields(['expressionfield']);
Then simple check it in a crud:
$crud->setModel($childmodel);
I checked further, the issue is that $this->ui['editable']
in Field:457 returns an array which includes true and false, rather than just a boolean value.
Thank you for the code. I am looking into it.
it relates to the missing isEditable() property of SqlExpressionField
really a property? I seached ->(is)?editable(?!\()
, no such property is accessed in the whole project
I belive the issue is caused by ui['editable']
beiing an array - https://github.com/atk4/data/blob/0892a701f955b5c560bb3dd324645788bedd7594/src/Field.php#L457
yes, doesn't it come from your code?
No, I haven't touched anything there, just standard model definitions
issue is here: https://github.com/atk4/data/blob/0892a701f955b5c560bb3dd324645788bedd7594/src/Reference/HasOneSql.php#L87
array_merge_recursive
is not merging the seed properly - https://3v4l.org/4Tgo8
Steps to reproduce:
Error
TypeError: Atk4\Data\Field::isEditable(): Return value must be of type bool, array returned
in Model:730The issue is in line 734, as isEditable is not existing as a property for SqlExpressionField.