Skip to main content

Relational-Combobox

Relational Combobox

ArtiGrid allows you to create relational dropdown fields in your forms using the combobox() method.
This makes it possible to select values from a related table instead of typing them manually.
It's especially useful for managing foreign key relationships in a database.

Below is an example showing how to use a relational combobox:

<?php
$grid = new ArtiGrid();
$grid->table('employees')
->template('bootstrap5')
->unset('filter', false)
->modal();
$grid->combobox('officeCode','offices','officeCode','city'); // The first parameter is the field to which you want to apply the combobox, the second parameter is the relational table, the third parameter is the id of the relational table, and the fourth parameter is the field of the relational table
echo $grid->render();
?>