Pass non-related for <model> data in form builder <select> from <another model> with custom query
I have a model with 4 relationships. But on create page I need to render additional select field that are not related with my model attributes and relationships.
When saving, this data from select fields must be converted into JSON contents to save select fields (initially not-related with my model) into JSONB.
Some select fields need to provide data from a large tables. This could be several million entries, for example, searching for a user by full name.
If I understand the documentation correctly, I cannot use the ->relationship(name: ..., titleAttribute: ...) method in this case - because it only works with related models. Or can it still be used for unrelated models?
How to provide data from unrelated table to my select?
I have 2 cases of using such selects:
2) In the second case, I want the page to be loaded with data from a small table when it is first loaded, so as not to wait for the search field in the select to send a request to the backend and return the data back. How to do it?
Please show me a usage example for all my questions.
When saving, this data from select fields must be converted into JSON contents to save select fields (initially not-related with my model) into JSONB.
Some select fields need to provide data from a large tables. This could be several million entries, for example, searching for a user by full name.
If I understand the documentation correctly, I cannot use the ->relationship(name: ..., titleAttribute: ...) method in this case - because it only works with related models. Or can it still be used for unrelated models?
How to provide data from unrelated table to my select?
I have 2 cases of using such selects:
- unrelated tables are highloaded
- unrelated tables are a small directory (less than 100 records in the table - for example, a list of regions).
2) In the second case, I want the page to be loaded with data from a small table when it is first loaded, so as not to wait for the search field in the select to send a request to the backend and return the data back. How to do it?
Please show me a usage example for all my questions.