Prepare a new registration button for the child model on the details screen of the parent model. Also, a child model new registration button is not prepared on the child model side. This realizes the operation that the (parents) parent always exists when there is child data .
We will take on two models of "customer" and "support".
First, open the support search screen from "Support search".At this point, no data has been registered.
The support model has a relationship of "which customer model support it?"Therefore, it is not possible to create a support model alone without specifying a customer model.(The "New registration" button is not displayed on the screen in Fig.)
Next, we will create new customer data.
The "Support new creation" button is prepared on the detail display screen of the customer.(Figure 2) To register a support model that is related to a foreign key, perform the new registration from the detail display screen of the target data (here, customer data).
Click the "Create new support" button and open the support new registration screen.The customer ID (the ID of the linked parent model) is set automatically and read-only.(You can not change parents.)
Enter each item and register."Customer list display" and "Customer details display" button for returning to the customer model from the support detailed display screen are prepared.
The "Register" button is hidden on the search/list screen of the child model (here, support model).
Make the foreign key (customer ID) of the child model read-only.