Closed Eighke closed 8 years ago
Neither is correct in your use case. You just need to use the built-in relations support in browse forms (NOT the Relation form field which is something else entirely)
$this->hasOne('user', 'Users', 'user_id', 'user_id');
$this->with['user']);
Eager loading consumes more memory (loads the N rows visible in the browse page) but is faster, lazy loading in a browse form will end up consuming the same or more memory and is much, much slower.name="user.username"
Regarding edit views, I'm afraid none of the built-in fields will make sense for tables with thousands to millions of rows. Remember, both the Relations and the Model field are designed to create drop-down lists. What you need is to open a popup form, e.g. like we do with user selection. There is no form field to do that mainly because it requires a special view template in your view and some Javascript on your form page.
Wait wait, you can loading relation using name="user.username" in the XML form? I stay in a cavern for too long... Thanks for the explanations. :)
(it is mainly for the browse view, in the edit view I had to use Select2 + autocompletion to limit the number of result).
Yup :D Go to https://github.com/akeeba/fof/wiki/XML-Forms#optional-attributes and look for relation_depth in that documentation chunk for more information.
Oh nice. Thanks :)
587
Nic,
Maybe I should give you more informations. I was never able to use Model field for this component. The Model field is eating my memory like crazy:
I need to add 200 Mo per Model field used in the XML (I have 3...). I'm currently migrating the component to FOF3 and I have nothing but XML form. The only way to decrease the memory leak is to decrease the number of row in the database...
I had this problem on many components, so I tried to find a solution. And using the relation work great. Even with 1 millions rows. :)
The second thing, even if I had low row in my table, it think it is more natural to use the relation than the model field.
There. :)