Many-to-many relations Default theme
Many-to-many (FK) relations can be displayed as simple multiselect fields. This method changes only fk table.
<?php
$xcrud = Xcrud::get_instance();
$xcrud->table('customers');
$xcrud->columns('customerNumber,Customer orders,city');
$xcrud->fk_relation('Customer orders','customerNumber','customers_orders_fk','customer_id','order_id','orders','orderNumber',array('orderNumber','orderDate'));
echo $xcrud->render();
?>
Customers
Customers
# | Customernumber | Customer orders | City | |
1 | 103 | 10394 2005-03-15 00:00:00 | Nantes | |
2 | 112 | 10103 2003-01-29 00:00:00 | Las Vegas | |
3 | 114 | | Melbourne | |
4 | 119 | 10101 2003-01-09 00:00:00, 10104 2003-01-31
| Nantes | |
5 | 121 | 10100 2003-01-06 00:00:00 | Stavern | |
6 | 124 | 10356 2004-12-09 00:00:00, 10357 2004-12-10
| San Rafael | |
7 | 125 | 10119 2003-04-28 00:00:00 | Warszawa | |
8 | 128 | 10101 2003-01-09 00:00:00, 10102 2003-01-10
| Frankfurt | |
9 | 129 | 10104 2003-01-31 00:00:00 | San Francisco | |
10 | 131 | 10103 2003-01-29 00:00:00, 10104 2003-01-31
| NYC | |