Cheat Sheet: ---------- Anatomy of a field definition (fdd) for a TEXT/BLOB field $opts['fdd']['content'] = array( 'default' => '', // TEXT fields are not generally defined in MySQL as having default entries 'help|ACP' => 'Hello World', // Message appearing in the Help cell if the page mode is Add, Change, or coPy 'input' => '', // Sometimes set as [R]ead-only, [H]idden, or [P]assword 'maxlen|ACP' => 65535, // Field length defined in MySQL 'name' => 'Content', // Column lable 'options' => 'ACPVD', // Page modes suppressed: [F]ilter, [L]ist 'select' => 'T', // Filter/Search box in List mode (set D for drop down) 'sqlw' => 'TRIM("$val_as")', // Apply MySQL's trim() function 'strip_tags|FL' => true, // Usually set true unless displaying HTML markup 'textarea' => array('rows' => '5', 'cols' => '58'), // Dimensions for the HTML TEXTAREA box 'trimlen|FL' => 50, // In [F]ilter and [L]ist modes display only the first 50 characters 'sort' => false // If set true, the column title is a sort link ); $opts['fdd']['content']['js']['required'] = true; // Entry is required $opts['fdd']['content']['js']['regexp'] = '/^[a-zA-Z]*$/'; // Optionally apply Javascript REGEXP $opts['fdd']['content']['js']['hint'] = 'Entry of Content is required'; // Contents of the Javascript alert ---------- Field options ['fdd'] can be restricted to specific page modes (ACPVDFLI), for example: 'help|ACP' or 'trimlen|FL' ---------- The following elements are available for use in a field definition arrays. 'colattrs' user-defined table cell attributes: 'colattrs|FL' => 'style="color:#ff0000;background-color:transparent"', 'css' user-defined style class (e.g. '-right-justify' is an MFG element, not a phpMyEdit element) 'datemask' applicable to TIMESTAMP(14) and DATETIME fields 'Y-m-d H:i:s' 'r' 'default' default values are extracted from MySQL NULL values, if found, are handled using the 'sqlw' element 'escape' if set to true, htmlspecialchars() will be applied to data (set false to display HTML markup) 'help|ACP' help / guidance displayed in ACP modes in a 3rd column (TD tag next to data) MFG offers several methods of initializing and/or populating this TD tag 'input' RWH (Readonly, passWord, Hidden) available since phpMyEdit version 5.4 R - indicates that a field is read only (TIMESTAMP or auto_increment) W - indicates that a field is a password field H - indicates that a field is to be hidden and marked as hidden 'mask' a string (e.g. '%01.2f') used by sprintf() to format output (see also number_format) 'maxlen' maxlength attribute in the display of INPUT boxes relating to add/edit/search 'name' title for column headings ... PHP's ucwords(strtolower(col_name)) 'nowrap' HTML NOWRAP attribute for TD tags 'number_format' emulates PHP's number_format() function 'options' ACPVDFLI - optional parameter to control whether a field is displayed: A - add, C - change, P - copy, D - delete, V - view, F - filter, L - list I - initial sort suppressed 'php' If the 'php' option is set, a file of that name is included (and executed) in place of a value. Behavior is the same as the triggers feature. http://platon.sk/projects/doc.php/phpMyEdit/html/configuration.fields.php.html 'required' true or false (true invokes javascript to prevent null entries) Do not use quotation marks (") withing the 'hint'. The above post-initialization example may be easier to work with than the following examples which might be applied directly to a field options array. 'js' => array( 'required' => true, 'regexp' => '/^[0-9]*$/', 'hint' => 'Please enter only numbers 0-9 in the col_name field.' ) 'js' => array( 'required' => true, 'regexp' => '/^[:digit:]*$/', 'hint' => 'Please enter only numbers 0-9 in the col_name field.' ) 'js' => array( 'required' => true, 'regexp' => '/^[:digit:]*$/', 'hint' => 'Please enter only numbers 0-9 in the col_name field.' ) 'select' HTML INPUT/SELECT box type used for filtering records T - text, N - numeric, D - drop-down, M - multiple selection Defining fields as ENUM or SET in MySQL will result in HTML SELECT boxes in Filter mode. 'size' size attribute applied to HTML INPUT boxes 'strftimemask' optinally applied to INT fields containing a Unix timestamp 'strftimemask' => '%c', 'strftimemask' => '%a %m-%d-%Y %H:%M %p', 'sort' In List mode, if set to true, the column header is a clickable link that enables column sorting. BLOB columns should usually be set to false. 'sql' see documentation, examples follow Transform an integer (Unix timestamp) to human readable date: 'sql|FLV' => 'if($col_name > "", CONCAT(DATE_FORMAT($col_name, "%a %b %e %Y %h:%i %p")), "")', 'sql|FLV' => 'if(FirstName <> "", CONCAT(LastName, ", ", FirstName), LastName)' 'sql|FLV' => 'if(start_date > "", CONCAT(start_date, "%b %e %Y - %a"), "")' 'sql|LV' => 'CONCAT(FROM_UNIXTIME(col_name, "%a %b %e %Y %h:%i %p"))', 'sql|LV' => 'if(FirstName <> "", CONCAT(LastName, ", ", FirstName), LastName)', 'sql|LV' => 'if(start_date > "", CONCAT(start_date, "%b %e %Y - %a"), "")', 'sql' => 'CONCAT(FROM_UNIXTIME(col_name, "%a %b %e %Y %h:%i %p"))' 'sqlw' 'sqlw' => 'TRIM(UPPER($val_as))' 'sqlw' => 'IF($val_qas = "", NULL, $val_qas)' 'strip_tags' apply PHP's strip_tags($col_name) 'tab|ACP' If tabs are enabled in the $opts['display'] array, apply clickable Javascript tabs (sub-forms) appear in ACP modes. Apply to column 0 and one (or more) additional fields. 'textarea' rows/cols attribute for HTML TEXTAREA boxes 'trimlen|FL' number of characters to display in [F]ilter and [L]ist modes (often applied to BLOB/TEXT fields) 'URL' used to make a field 'clickable' in the display for email addresses: 'mailto:$value' where the value might be www.domain.com: 'http://$value' where the value might be http://www.domain.com: '$value' 'URLtarget' HTML A HREF target parameter, e.g. 'target="_blank"' 'values' $opts['fdd']['col_name']['values'] = array('0', '1', '2', '3'); 'values2' $opts['fdd']['col_name']['values2'] = array('0' => 'No', '1' => 'Yes'); ---------- Extract 'values' from a different table (initialization): $opts['fdd']['field_name'] = array( 'default' => '', 'maxlen' => 20, 'name' => 'Field Name', 'options' => 'ACPVDFL', 'required' => true, 'select' => 'T', 'size|ACP' => 20, 'sort' => true, 'values' => array( 'db' => 'databaseName', 'table' => 'extractTable', 'column' => 'extractColumn', 'description'=> array( 'columns' => array('0' => 'name', '1' => 'father_name', '2' => 'mother_name'), 'divs' => array('0' => ' - ', '1' => ' - '), ), 'filters' => 'col_name = "criteria"', 'orderby' => 'yet_another_col') ); $opts['fdd']['dummy1'] = array ( 'name' => 'Dummy Field', 'sql' => 'CONCAT(first_name, " ", last_name)', 'options' => 'VDL', 'escape' => false, 'sort' => true ); ---------- Extract 'values' from a different table (post-initialization may enhance readability): $opts['fdd']['col_name']['values']['db'] = 'databaseName'; $opts['fdd']['col_name']['values']['table'] = 'extractTable'; $opts['fdd']['col_name']['values']['column'] = 'extractColumn'; $opts['fdd']['col_name']['values']['description']['divs']['-1'] = ', '; $opts['fdd']['col_name']['values']['description']['columns']['0'] = 'desc_column_0'; $opts['fdd']['col_name']['values']['description']['divs']['0'] = ', '; $opts['fdd']['col_name']['values']['description']['columns']['1'] = 'desc_column_1'; $opts['fdd']['col_name']['values']['filters'] = 'id = "something" '; $opts['fdd']['col_name']['values']['orderby'] = 'another_column'; $opts['fdd']['dummy1'] = array ( 'name' => 'Dummy Field', 'sql' => 'CONCAT(first_name, " ", last_name)', 'options' => 'VDL', 'escape' => false, 'sort' => true ); ---------- Global record filters facilitate working with a subset of records: $opts['filters'] = 'valid_user = "'.$_SESSION['valid_user'].'" OR valid_user = "public"'; $opts['cgi']['persist'] = array('vrec' => $_REQUEST['vrec'] ); See also filters_a-z.txt $opts['filters'] = "PMEtable0.active = '1'"; $opts['filters'] = "PMEtable0.deleted = '0'"; $opts['filters'] = "PMEtable0.column1 like '%11%' AND column2<17"; $opts['filters'] = "PMEtable0.section_id = 9"; $opts['filters'] = "PMEtable0.sessions_count > 200"; ---------- CGI variables: $opts['cgi']['overwrite']['DateCreated'] = date('Y-m-d'); $opts['cgi']['persist'] = $your_variable; $opts['cgi']['persist'] = array('article_id' => $article_id, 'session_id' => $session_id); ---------- Notification examples: $opts['notify']['from'] = 'user@domain.com'; $opts['notify']['prefix'] = $_SERVER['REQUEST_URI'].' - '; $opts['notify']['wrap'] = '72'; $opts['notify']['all'] = 'user@domain.com'; // events: insert, update, delete $opts['notify']['delete'] = 'user@domain.com'; // event: delete $opts['notify']['insert'] = 'user@domain.com'; // event: insert $opts['notify']['update'] = 'user@domain.com'; // event: update ---------- Forum post regarding usage of the 'php' option to call external PHP scripts: http://platon.sk/forum/projects/viewtopic.php?t=1569821 spudnukem - Post Posted: 08 Dec 2010 13:54 Hi, probably could be done better but this is how I got different link types in a value ie skype, mailto and pbx or any other call based on a contact type field and an address from another field .... hope it helps someone! $opts['fdd']['conType'] = array( 'name' => 'conType', 'select' => 'D', 'php' => 'test.php', 'values' => array('Skype','Email','Phone','NONE'), 'maxlen' => 60, 'default' => '0', 'sort' => true ); $opts['fdd']['address'] = array( 'name' => 'Address', 'select' => 'T', 'escape' => false, 'maxlen' => 60, 'sort' => true ); and in my test.php; skype'; }elseif($value == 'Email'){ echo 'email'; }elseif($value == 'Phone'){ echo 'phone'; }else{ echo $value; } return; ?> ---- CONCAT & REPLACE $opts['fdd']['dummy2'] = array ( 'name' => 'Thumbnail', 'sql|VLF' => 'if(category = "other", CONCAT("link"), if(category = "thumb", CONCAT("\"\"
Replace"), ""))', 'options' => 'VLF', 'input' => 'R', 'escape' => false, 'sort' => false );