Support > Repository > Parent-child relationship > Make sure that you can not create a child model unless the parent model exists
ja | en

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.)

Figure 1 Support Search Screen

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 registration from the detail display screen of the target data (customer data here).

Figure 2 Customer details display screen

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.)

Figure 3 Support new registration screen

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.

Figure 4 Support detail screen

Search and list screen of child models

The "Register" button is hidden on the search/list screen of the child model (here, support model).

Fig. 6 Do not display new registration button

Make a foreign key readonly

Make the foreign key (customer ID) of the child model read-only.

Figure 7 Making external key fields readonly