Page 1 of 1

Struggling with subform with no success

Posted: Sun Apr 04, 2021 5:57 am
by absalom
Hi, I can't manage to figure out how to make a subform in a very simple situations; tried to match some online tutorials but can't make it work.

I have a very simple customer/orders situation: an "edit" form for a single customer, and I would like to browse orders from that customer. Of course, orders.customer_id is a foreign key to customer.id

What I did:

* have an "edit" form for the customer;
* put a "subform" object at the relevant location in the previous "edit" form (in the "subform" tab of this objects, I set the following form in the Form field and put customer_id in the Foreign key field despite the fact that no table can be referred to here)
* have a "browse" form for the orders with

Code: Select all

select * from orders where customer_id = #ID#
as SQL

But I see nothing; actually, I see the subform object but empty (empty means that I don't even see empty columns for the browse form).

After browsing a little here, I noticed the recent question: https://forums.nubuilder.cloud/viewtopic.php?f=19&t=10925
which tells about a "Run" object rather than a "Subform" one, but I thought that the Subform was exactly for what I need. Why doesn't it work on such a simple case?

Re: Struggling with subform with no success

Posted: Sun Apr 04, 2021 6:52 am
by kev1n
Hi,

This is SQL is sufficient.

Code: Select all

select * from orders
nuBuilder will create the relation to the customer table automatically.


I created a small demo here:
https://test.nubuilder.cloud/index.php? ... 1&h=nuhome

What I did:

1) Create a Form/table customer:

(cus_firstname and cus_lastname are "Input:Text" and cus_orders is a Subform)
customer.png
2) Create a Subform Form/table item:
(itm_description is "Input:Text" and itm_quantity "Input:Number"
item.png
Then open the customer Form and connect its Subform:
connect_subform.png

Re: Struggling with subform with no success

Posted: Sun Apr 04, 2021 10:40 am
by absalom
Thank you; now it works.

How can I prevent rows to be deletable (I don't want the right checkbox to be displayed)?

Re: Struggling with subform with no success

Posted: Sun Apr 04, 2021 10:43 am
by kev1n
Set Deleteable to No