subform / insert items

mrisse

New member
Hi,

I didn't get how subforms are working. my challenge:
I need a form to create orders. it should be possible to add one or more items to the order.
Example: a cake bakery:

order no: 123
customer no: 456
date: 01.01.11

the items:
cake1:
- type: strawberry-cake,
- size: 24cm
- print: "Happy Birthday"

cake2:
- type: cheesecake
- size: 24cm
- print: "Thanks Mom"


The number of cakes is always different. How can I do this when placing an order? It should be possible in one form (page).

I think I need a howto :-/
 

eugenio

Administrator
Staff member
Hello,
is what you want to get similar to what you see in demo n.1 -> Sales -> Quotes -> edit a quote? If yes, you have to play, in form configurator, ONLY for the primary key of your table ORDERS, with the "Master/details view".

Watch the first tutorial here:
https://dadabik.com/low-code-application-development-the-DaDaBIK-way
around minute 18 you will see the process.

Best,
 

mrisse

New member
Hello eugenio,

yes, the quotes in demo #1 is what i need!!
now i have to think about the database and table layout :)

Thank you!
 

mrisse

New member
I've got one problem:
when I create a new order, I'm not able to add items to the order. I have to safe the order first. after that I can add items by editing the order?!?! :-/
Any tipps?
 

eugenio

Administrator
Staff member
Hello,
yes, you have to insert the order first. If, right after the insertion, you want to add items, you could add an after insert hook that redirect to the edit form; however, this saves just one click (the click on the edit button).

Best,
 

mrisse

New member
Hello Eugenio,

my redirect-Hook isn't wortking. I tried both variants, what is the best/correct way to redirect?

[pre]
$hooks['auftrag']['insert']['after'] = 'dadabik_redirect_auftrag_to_edit';
function dadabik_redirect_auftrag_to_edit($id_auftrag)
{

//first try
echo '<META HTTP-EQUIV="Refresh" CONTENT="0; URL=index.php?tablename=auftrag&function=edit&where_field=id_auftrag&where_value='.$id_auftrag.'">';

// second try
header('Location:'.$dadabik_main_file.'?tablename=auftrag&function=edit&where_field=id_auftrag&where_value='.$id_auftrag);
}

[/pre]
 

eugenio

Administrator
Staff member
Hello,
there are a couple of things to fix but when you say it doesn't work what do you mean exactly, do you get an error message? What happens?

best,
 
Top