Original Source
https://pdocrud.com/demo/pages/multi-lang-data
https://pdocrud.com/demo/pages/rtl-support
https://pdocrud.com/demo/pages/add-captcha
https://pdocrud.com/demo/pages/recaptcha
https://pdocrud.com/demo/pages/dynamic-js-actions
Multi language data
PDOCrud supports multi language data insertion also. Please make sure the database table "Collation" is correct. By default, character encoding is set to utf8. You can change this encoding as per your requirement using either config or setting.
$pdocrud = new PDOCrud();//create object of PDOCrud Class
echo $pdocrud->dbTable("multi_lang")->render(); // call render function on database table
Right to Left Support
Right to left support can be added using the bootstrap-rtl or any other rtl css file. For bootstrap rtl, You can enqueue the rtl css file to acheive RTL.
pdocrud = new PDOCrud();//create object of PDOCrud Class
$pdocrud->enqueueCss("bootstrap-rtl", "https://cdnjs.cloudflare.com/ajax/libs/bootstrap-rtl/3.2.0-rc2/css/bootstrap-rtl.min.css");
echo $pdocrud->dbTable("orders")->render(); // call render function on database table
Captcha Field
$pdocrud = new PDOCrud();
$pdocrud->formAddCaptcha("captcha");//to add captcha
echo $pdocrud->dbTable("users")->render();
Recpatcha
You can add recaptcha easily PDOCrud. You will only need to get the site key and secret key from google.
$pdocrud = new PDOCrud();
$pdocrud->recaptcha("your-site-key","site-secret");//site key and site secret
echo $pdocrud->dbTable("employee")->render("insertform");
Dynamic javascript action
You can apply simple math functions to calculate fields using javascript. For example, if you want to get sum of two or more fields, or get sum of field with multiplication.
In the below example, we are getting sum of three fields and substracting one field on change event. If you don't specify the $eventFields argument then it will automatically apply change event on each of the formula fields so it will calculate on the change on the all these four fields.
$pdocrud = new PDOCrud();
/**
* Set/Call js actions for the form elements on some js event
* @param string $element Main element, On which element, calculated value should be displayed
* @param string $formula Formula to be applied
* @param string $event Javascript event, this will be applied on formula fields if no event fields passed
* @param string $eventFields Event fields if any
* return object Object of class
*/
$pdocrud->setJsActions("order_total", "{order_sub_total} + {tax} + {shipping} - {discount}","change");
echo $pdocrud->dbTable("x_ordertable")->render("insertform");
Set Search Col Data Type
You can set search col data type to date/datetime/time etc to make search more friendly. Default type is text. For example When you set search column data type to date-range, it will show date range options.
$pdocrud = new PDOCrud();
//set the search column data type
$pdocrud->setSearchColumnDataType("order_date", "date-range");// other options are time-range, datetime-range
echo $pdocrud->dbTable("orders")->render();
SQL Operation
Render sql helps to display the data in grid/table format. You can write sql select statement to display data in the grid format. Please note that since sql statement can be of any type so the default grid function will not work with this sql render. From version 2.4, the pagination, records per page and display of total records is also removed. A better option to use the sql render with the jquery datatable plugin. You can see example here
$pdocrud = new PDOCrud();
$pdocrud->setQuery("select * from orders");
echo $pdocrud->render("SQL");
Subselect SQL
You can use the subselect query to generate columns dynamically. You can get data from other tables using the query. It accepts two parameters, first one is column name/alias and second is query.
$pdocrud = new PDOCrud();
$pdocrud->crudTableCol(array("first_name","last_name"));
/**
* Allows you to add the dynamic column based on sub query
* @param string $columnName Alias column name to be used for the query
* @param string $query Sub Query to be used
* return object Object of class
*/
$pdocrud->subQueryColumn("order_id", "select sum(id) from orders where customer_name = {user_name}");
echo $pdocrud->dbTable("users")->render()