DEMO SITE v1.7.32

Disable Fields - Logic 1.7.24 Tailwind CSS 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

Add
#OrderdateStatusRequireddateShippeddateComments
Actions
12003-02-20 00:00:00Shipped2020-07-29 00:00:0030.07.2020 00:00:00Great View Edit Remove
22003-01-10 00:00:00Shipped2003-01-18 00:00:0014.01.2003 00:00:00Great Great View Edit Remove
32003-01-29 00:00:00Shipped2003-02-07 00:00:0002.02.2003 00:00:00MMM View Edit Remove
42003-01-31 00:00:00Shipped2003-02-09 00:00:0019.02.2003 00:00:00Hi View Edit Remove
52003-02-11 00:00:00Shipped2003-02-21 00:00:0012.02.2003 00:00:00Item 1 View Edit Remove
62003-02-17 00:00:00Shipped2003-02-24 00:00:0021.02.2003 00:00:00Great Item View Edit Remove
72003-02-24 00:00:00Shipped2003-03-03 00:00:0026.02.2003 00:00:00Difficult to negotiate with customer. We need… View Edit Remove
82003-03-03 00:00:00Shipped2003-03-12 00:00:0008.03.2003 00:00:00 View Edit Remove
92003-03-10 00:00:00Shipped2003-03-19 00:00:0011.03.2003 00:00:00Customer requested that FedEx Ground is used for… View Edit Remove
102003-03-18 00:00:00Shipped2003-03-24 00:00:0020.03.2003 00:00:00 View Edit Remove
Showing 1 to 10 of 327
Search