jeudi 30 juin 2016

add multi columns in many-to-many relation using fk-relation in xcrud


I have three tables :

orders :

id_order PK int
id_client
.
.
.
etc ...

Products :

id_product PK int
product_name  varchar(255)
.
.
.
etc ...

orders_products

id  PK int
id_order  FK int
id_product   FK int
quantity    int
discount    float

and Im using Xcrud as a crud framework based.

this is my code :

    $xcrud = Xcrud::get_instance();
    $xcrud->table('orders');
    $xcrud->fk_relation('Products','id_order','orders_products','id_order','id_product','products', 'id_product','product_name');
  • So each order has multi products
  • And each product has a quantity

When I go to add an order it only shows me a multiselect field of products and it's inserting products find in the orders_products table.

but I want to add for each product a quantity.

How can I do that using xcrud ?


Aucun commentaire:

Enregistrer un commentaire