Hide Fields-Logic 1.7.24 Bootstrap 5 theme
Hide fields based on an input or selected logic. For this instance selecting status "Shipped" will hide Requireddate and Shippeddate
HIDE CODE
<?php
// Get an instance of the Xcrud class
$xcrud = Xcrud::get_instance();
// Set the table to work with
$xcrud->table("orders");
// Define which columns to display in the table
$xcrud->columns("orderDate,status,requiredDate,shippedDate,comments");
// Define which fields are available for data entry or editing
$xcrud->fields("orderDate,status,requiredDate,shippedDate,comments");
// Change the input type of the 'status' field to a select dropdown and provide options
$xcrud->change_type("status","select","",array("Not Shipped"=>"Not Shipped","Shipped"=>"Shipped","Completed"=>"Completed"));
// Hide the 'requiredDate' field when the 'status' is 'Shipped'
$xcrud->hide_logic("requiredDate","status","=","Shipped");
// Hide the 'shippedDate' field when the 'status' is 'Shipped'
$xcrud->hide_logic("shippedDate","status","=","Shipped");
// Render the xcrud instance to display the table and form
echo $xcrud->render();
?>
Orders
| # | Orderdate | Status | Requireddate | Shippeddate | Comments | |
|---|---|---|---|---|---|---|
| 1 | 01.07.2003 00:00:00 | Shipped | 10.07.2003 00:00:00 | 05.07.2003 00:00:00 | gfchchf rtrtyrty | View Edit Remove |
| 2 | 02.07.2003 00:00:00 | Shipped | 12.07.2003 00:00:00 | 03.07.2003 00:00:00 | NULL | View Edit Remove |
| 3 | 01.08.2003 00:00:00 | Shipped | 09.08.2003 00:00:00 | 04.08.2003 00:00:00 | View Edit Remove | |
| 4 | 08.08.2003 00:00:00 | Shipped | 16.08.2003 00:00:00 | 13.08.2003 00:00:00 | View Edit Remove | |
| 5 | 10.08.2003 00:00:00 | Shipped | 18.08.2003 00:00:00 | 12.08.2003 00:00:00 | Can we deliver the new Ford Mustang models by | View Edit Remove |
| 6 | 13.08.2003 00:00:00 | Shipped | 21.08.2003 00:00:00 | 14.08.2003 00:00:00 | View Edit Remove | |
| 7 | 25.08.2003 00:00:00 | Shipped | 02.09.2003 00:00:00 | 31.08.2003 00:00:00 | View Edit Remove | |
| 8 | 03.09.2003 00:00:00 | Shipped | 13.09.2003 00:00:00 | 06.09.2003 00:00:00 | View Edit Remove | |
| 9 | 05.09.2003 00:00:00 | Shipped | 12.09.2003 00:00:00 | 09.09.2003 00:00:00 | View Edit Remove | |
| 10 | 11.09.2003 00:00:00 | Shipped | 21.09.2003 00:00:00 | 15.09.2003 00:00:00 | They want to reevaluate their terms agreement | View Edit Remove |