You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But most of the time data models contain a lot of data and DropDown field always loads all records from referenced model and renders all its elements. This is very time and resource heavy and in case referenced data model is huge - it can even crash.
// this will by default use \atk4\ui\FormField\DropDown field in forms
// DropDown field loads all its values instantly and renders them, so
// in case of huge data model this will be slow and resource heavy.
$this->hasOne('a_id', new HugeModel());
// To use much nicer and faster alternative use \atk4\ui\FormField\Lookup
// field. It will load only few records and use ajax to load other records
// as soon as you start typing something in lookup field. So this will work
// fast and will not be resource heavy and most likely should be as default
// field for hasOne relation sometime in future.
$this->hasOne('b_id', [new HugeModel(), 'ui'=>['form'=>new \atk4\ui\FormField\Lookup()]]);
In case of big referenced data model we should use Lookup field by default to help developers avoid these issues mentioned above.
So it will still use DropDown for enum and values because these are _static ones_and most likely not a big data amount, but use Lookup field by default in case of hasOne reference, because models most likely will have a lot of data.
The text was updated successfully, but these errors were encountered:
Currently we use \atk4\ui\FormField\DropDown field by default for hasOne fields.
See https://github.com/atk4/ui/blob/develop/src/Form.php#L383 and below.
But most of the time data models contain a lot of data and DropDown field always loads all records from referenced model and renders all its elements. This is very time and resource heavy and in case referenced data model is huge - it can even crash.
In case of big referenced data model we should use Lookup field by default to help developers avoid these issues mentioned above.
So my proposal is to replace this:
with this:
So it will still use DropDown for enum and values because these are _static ones_and most likely not a big data amount, but use Lookup field by default in case of hasOne reference, because models most likely will have a lot of data.
The text was updated successfully, but these errors were encountered: