DEMO SITE v1.7.31

Disable Fields - Logic 1.7.24 Minimal theme

Hide fields based on an input or selected logic. For this instance selecting status "Shipped" will disable 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");

    $xcrud->change_type("orderDate","flatpickr","","{enableTime:false,dateFormat:Y-m-d H:i:s,locale:it,altFormat:d-m-Y,altInput: true}");//"{enableTime:true,dateFormat:Y-m-d H:i:s,locale:it,altFormat:d-m-Y H:i:s,altInput: true}
    $xcrud->change_type("requiredDate","flatpickr","",'{enableTime:false,dateFormat:Y-m-d H:i,locale:it,altFormat:d-m-Y,altInput: true}');
    //$xcrud->change_type("shippedDate","flatpickr","",'{enableTime:true,dateFormat:Y-m-d H:i,locale:it,altFormat:d-m-Y,altInput: true}');
   
    // 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"));

    // Disable the 'requiredDate' field when the 'status' is 'Shipped'
    $xcrud->disable_logic("requiredDate","status","=","Shipped");

    // Disable the 'shippedDate' field when the 'status' is 'Shipped'
    $xcrud->disable_logic("shippedDate","status","=","Shipped");

    // Render the xcrud instance to display the table and form
    echo $xcrud->render();	
?>

Orders

#OrderdateStatusRequireddateShippeddateComments
12003-10-18 00:00:00Shipped2003-10-26 00:00:0019.10.2003 00:00:00 View Edit Remove
22003-10-20 00:00:00Shipped2003-10-27 00:00:0024.10.2003 00:00:00 View Edit Remove
32003-10-21 00:00:002003-10-30 00:00:0023.10.2003 00:00:00This order was disputed, but resolved on… View Edit Remove
42003-10-22 00:00:00Shipped2003-10-31 00:00:0026.12.2003 00:00:00This order was on hold because customers's credit… View Edit Remove
52003-10-21 00:00:00Shipped2003-10-30 00:00:0027.10.2003 00:00:00 View Edit Remove
62003-10-23 00:00:002003-10-30 00:00:00Customer called to cancel. The warehouse was… View Edit Remove
72003-10-28 00:00:00Shipped2003-11-03 00:00:0001.11.2003 00:00:00 View Edit Remove
82003-11-04 00:00:00Shipped2003-11-14 00:00:0009.11.2003 00:00:00 View Edit Remove
92003-11-04 00:00:00Shipped2003-11-12 00:00:0007.11.2003 00:00:00 View Edit Remove
102003-11-05 00:00:00Shipped2003-11-13 00:00:0007.11.2003 00:00:00 View Edit Remove
Add Export into CSV Print Search