Formula based field content formatting
Message :
Products
Showing 1 to 5 of 107 entries

You can apply basic formula to change value of the field before insert/update operation dynamically. It can be done using the callback function also but this function is added to provide more convenient way to do same. It also helps to set the value to NULL for empty values to help to enter data in case of database restriction for e.g. saving NULL for datetime for empty values.
$pdocrud = new PDOCrud(); // format field to 2 decimal point $pdocrud->fieldFormula("tax", "formula",array("type" =>"round","decimalpoint"=>2)); // format field to 2 decimal point $pdocrud->fieldFormula("product_discount", "formula",array("type" =>"number_format","decimalpoint"=>2)); // get ceil value of field $pdocrud->fieldFormula("product_price", "formula",array("type" =>"ceil")); //get floor value of field $pdocrud->fieldFormula("product_sell_price", "formula",array("type" =>"floor")); //string type - adding prefix of sku always and checking for duplicate i.e. string already have sku or not $pdocrud->fieldFormula("product_id","string",array("type" =>"prefix","str"=>"SKU_","duplicate"=>true)); //make product name first letter upper case $pdocrud->fieldFormula("product_name", "string",array("type" =>"uppercase")); //setting value to NULL if empty $pdocrud->fieldFormula("added_Date", "string",array("type" =>"null")); echo $pdocrud->dbTable("products")->render();