In my UI there is forms to create new Groups. The Group model has a hasOne Relation:
... $this->hasOne('group_origin_id', new GroupOrigin()); ...
And I would like to set the default for this field so its pre-selected in the form dropdown.
The atk4\data\Field class has a default property, but I am having a hard time setting it, this does not work:
... $this->hasOne('group_origin_id', new GroupOrigin()); $this->group_origin_id->default = 1; ...
It creates the following PHP warning:
Warning: Creating default object from empty value in /var/www/html/TourManagement/src/Group.php on line 24
It seems as “default” is used in a keyword in PHP, it does not work - or am I wrong?
Any other way to get the wanted behaviour? To set the default in the model would be the most sensible place, as any form will automatically use the default.