Answer the question
In order to leave comments, you need to log in
How to do competently CRUD for two tables of related tables, if there is a possibility of missing data in the second one?
There are 2 tables: Service
table
Responsible for storing services.
Fields: id, name, cost, price, min, max. service_api
table
Some services may have API settings, some may not (handled manually).
Fields: service_id(&service=>id), order_link, check_link The
question is how to properly display and edit data for these two tables, provided that:
Not every service has its own API settings, but each API settings has its own service .
At the moment, I have a problem specifically with creating and saving, that is, how to implement it without JS.
In terms of saving, there is an idea: to make a ServiceForm form, which will have the properties of both the Service and ServiceApi tables.
And if, when creating services, the user did not fill in the fields of the service_api table, namely: order_link, check_link - check this and pull the method that will save only data to the service table. But then the question is when editing: how to display data on the form? You can, of course, make a check on the Controller'e whether the service has API settings and if not, display one form, if there is another. But this method seems too cumbersome and not the most correct.
Perhaps there is a more elegant solution?
Answer the question
In order to leave comments, you need to log in
Some services may have API settings
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question