// set which form fields to display. It sets fields for both insert and edit form.
$pdocrud->formFields(array("first_name","last_name","Address")); // function to set form fields in both insert and edit
// If you want seperate fields for edit form then insert form, you can set using below function.
$pdocrud->editFormFields(array("first_name","Address"));//added in v 3.3
//
$pdocrud->fieldTypes("user_image", "FILE_NEW");//
$pdocrud->fieldTypes("user_image", "image"); // CHANGE FILE TYPE TO IMAGE
$pdocrud->fieldTypes("user_image", "FILE_MULTI");
//
$pdocrud->fieldDisplayOrder(array("personalinfo"));
$pdocrud->fieldRenameLable("customer_name", "Client name");
$pdocrud->fieldHideLable("order_status");
$pdocrud->fieldDesc("last_name", "Last Name - some dummy description");
$pdocrud->fieldTooltip("user_name", "Please enter your user name to be used for login purpose");
$pdocrud->fieldGroups("Name",array("first_name","last_name"));
$pdocrud->fieldGroups("Personal",array("phone","gender","birth_date"));
$pdocrud->fieldDisplayOrder(array("first_name","last_name","phone", "gender", "birth_date"));
$pdocrud->fieldNotMandatory("phone");
$pdocrud->fieldAttributes("customer_name", array("placeholder"=>"name of customer"));
$pdocrud->fieldAttributes("email", array("data-type"=>"email"));
$pdocrud = new PDOCrud(false, "", "", array("resetForm" => true)); // RESETS FORM AFTER SUBMISSION
//
$pdocrud->fieldTypes("product_image", "image");
$pdocrud->formFields(array("product_image","product_id"));
//
$pdocrud->formRedirection("http://google.com");
$pdocrud->formDisplayInPopup(); // CALL THIS FUNCTION TO SHOW FORMS IN POPUP
$pdocrud->formDisplayInPopup("Open Order Details popup","Order Details", true); // POPUP FORM WITH BUTTON CLICK
//
// STATIC FIELDS
$pdocrud->formStaticFields("personalinfo", "html", "1.Personal Info
Enter your personal information");
$pdocrud->formStaticFields("terms_and_conditions", "checkbox", array("I accept the terms and condition"));//
$pdocrud->formStaticFields("hidden_field", "hidden", array("some value"));
//
// *Set a value of field
*@param string $fieldName field name to renamed
*@param string $value value of the field
*@param bool $fieldHidden Wheter that field is hidden or not
*@param string $tablename Tablename = Required only when using join table field name
*return object Object of class
$pdocrud->formFieldValue("customer_id", "1");//set some default value for customer Id
$pdocrud->fieldDataAttr("customer_id", array("disabled"=>"disabled")); // SHOW FIELD BUT CANT EDIT
$pdocrud->fieldHideLable("customer_id");
$pdocrud->fieldDataAttr("customer_id", array("style"=>"display:none"));
$pdocrud->formFieldValue("payment_method", "cash", true);// SET SOME DEFAULT VALUE
//first parameter is name of database field to be mapped, 2nd parameter is field type, 3rd parameter is value to be set, 4th parameter needs to be set "db"
$pdocrud->formStaticFields("customer_id_field", "hidden", array("33"),"db", "customer_id"); //add hidden field
//
$pdocrud->formAddCaptcha("captcha");
$pdocrud->recaptcha("your-site-key","site-secret");
//
echo $pdocrud->dbTable("users")->render("insertform"); // ADD TO THE END OF THE CODE
echo $pdocrud->dbTable("orders")->render("VIEWFORM",array("id" =>"58")); // ADD TO THE END OF THE CODE
echo $pdocrud->dbTable("orders")->render("EDITFORM",array("id" =>"58")); // ADD TO THE END OF THE CODE
//
// Field Types and Binding
$pdocrud->fieldTypes("about_yourself", "textarea");
$pdocrud->fieldTypes("gender", "radio");
$pdocrud->fieldDataBinding("gender", array("male","female"), "", "","array");
$pdocrud->fieldTypes("hobbies", "checkbox");
$pdocrud->fieldDataBinding("hobbies", array("Dance","Art","Games"), "", "","array");
$pdocrud->fieldTypes("hobbies", "checkbox");
$query = "select * from `hobbies` where `hobby_status` = 1 order by `hobby_name`";
$pdocrud->fieldDataBinding("hobbies", $query, "hobby_id", "hobby_name", "sql");
$pdocrud->fieldTypes("state", "select");
$pdocrud->fieldDataBinding("state", array("Andhra Pradesh","Bihar","Patna","Gujarat","Madhya Pradesh"), "", "","array");
$pdocrud->fieldTypes("city", "select");
$pdocrud->fieldDataBinding("city", "city", "city_id", array("city_code","city_name"), "db", "-");// USE DATA FROM ANOTHER TABLE
//Add 'where' and 'orderby' statement.
$pdocrud->fieldTypes("city", "select");
$pdocrud->fieldDataBinding("city", "city", "city_id", array("city_code","city_name"), "db", "-", array(array("city_code","0001","=")), array("city_name")); // WHER AND ORDER BY
$pdocrud->fieldTypes("country", "multiselect");
$pdocrud->fieldDataBinding("country", array("India","Brazil","UK","Pakistan"), "", "","array");
$pdocrud->fieldDependent("billing_state", "billing_country", "country_id"); //now on change of country it will change state
//
// Email Form
$pdocrud->formFields(array("first_name","last_name","email","message"));
$subject = "Email from {{first_name}} {{last_name}}";
$message = "default_template";// this will display all fields in table format in email
//You can also define message new template as below
//$message = "first_name:{{first_name}}
last_name:{{last_name}}
message:{{message}}
";
$pdocrud->formSendEmail("info@pdocrud.com",array("someemail@gmail.com"),$subject,$message);
echo $pdocrud->setLangData("save", "Sign me up!")->dbTable("contact")->render("emailform");
//
$pdocrud->fieldCssClass("first_name", array("class1", "class2"));// ADD CSS CLASSES
$pdocrud->fieldAttributes("last_name", array("data-type"=>"some_val"));// ANY ATTRIBUTE NAME AND ITS VALUE
//
// CONDITIONAL LOGIC - FORM
// when city is other then hide state and zip code else show
$pdocrud->fieldConditionalLogic("city", "Other", "=", "State", "hide");
$pdocrud->fieldConditionalLogic("city", "Other", "=", "Zip", "hide");
$pdocrud->fieldConditionalLogic("city", "Other", "!=", "State", "show");
$pdocrud->fieldConditionalLogic("city", "Other", "!=", "Zip", "show");
//
// FIELD VALIDATIONS
$pdocrud->fieldValidationType("user_name", "data-minlength", "10", "Please enter atleast 10 characters");
$pdocrud->fieldValidationType("password", "data-match", "confirm_password", "Password and confirm password not matching");
$pdocrud->formStaticFields("confirm_password", "text");
//
// FIELD FORMULAS
$pdocrud->fieldFormula("tax", "formula",array("type" =>"round","decimalpoint"=>2));// FORMAT TO 2 DECIMAL POINT
$pdocrud->fieldFormula("product_discount", "formula",array("type" =>"number_format","decimalpoint"=>2));
$pdocrud->fieldFormula("product_price", "formula",array("type" =>"ceil"));
$pdocrud->fieldFormula("product_sell_price", "formula",array("type" =>"floor"));
$pdocrud->fieldFormula("product_id","string",array("type" =>"prefix","str"=>"SKU_","duplicate"=>true));
$pdocrud->fieldFormula("product_name", "string",array("type" =>"uppercase")); // FIRST LETTER UPPERCASE
$pdocrud->fieldFormula("added_Date", "string",array("type" =>"null")); // SET VALUE TO NULL IF EMPTY
$pdocrud->fieldAddOnInfo("order_amount", "before", '$');// BEFORE ADDON
$pdocrud->fieldAddOnInfo("customer_name", "after", '@');// AFTER ADDON
//
// MILTI STEP FORMS
$pdocrud->FormSteps(array("first_name", "last_name", "email", "phone", "gender","birth_date"), "General Info","tabs");
$pdocrud->FormSteps(array("user_name", "password"), "Login Details","tabs");
$pdocrud->FormSteps(array("address", "city", "state", "country", "zip_code"), "Address","tabs");
$pdocrud->FormSteps(array("hobbies", "educational_status", "about_yourself", "company_name"), "Other","tabs");
//
// RELATED DATA
*Get related column data as list from other tables
*@param string $mainTableCol Column name of the main table
*@param string $relTable Related table name
*@param mixed $relTableCol Matching related table columns
*@param mixed $relDisplayCol Related table column to be display
*@param array $where where condition array
*@param array $orderby Order by condition array
*@param mixed $fieldType Field type to be displayed for that field, default is "select", if empty, then textarea will be shown
*return object Object of class
$pdocrud->relatedData('class_id','class','class_id','class_name');
// complete example of the related data function
// ** Please note that this will be applied in the form fields not in the grid
// $pdocrud->relatedData('class_id','class','class_id','class_name',array(array("class_id", 1,">=")), array("class_name"));