Search Form Fields

How to use the Search Field addField() and all it's parameters

The Search field parameters are as follow:

 

addField([
   'type'=>'search', //required
   'attributes'=>'required autofocus', //optional
   'label'=>'FIND CLIENT', //required
   'name'=>'CLID', //optional
   'ID'=>'MAINCLID', //optional
   'value'=>'',  //optional (required on edit to preserve value)
   'text'=>'',  //optional, the text to be shown instead of placeholder when a value exists (required on edit to preserve value)
   'placeholder'=>'SEARCH CLIENT NAME, EMAIL or COMPANY', //optional
   'data'=>[ //required
      'searchCols'=>'CLID,NAME,COMPANY,EMAIL,LNAME', //required
      'table'=>'CLIENTS', //required
      'colID'=>'CLID', //required
      'order' => 'CLIENTS.COMPANY ASC', //optional
      'where' => 'CLIENTS.ACTIVE = 1', //optional
      'limit' => 20,  //optional 20 by default
      'format'=>'<b>COMPANY</b>, NAME, LNAME,<br/>&lt;EMAIL&gt;', //optional &lt;EMAIL&gt; shows <EMAIL>
      'callback' => 'gotoClient();',  //optional
      'result'=>'COMPANY,NAME,LNAME,EMAIL'  //required
   ]
]);

 

In the case where a JOIN is required, do so in the TABLE value.

 

'table'=>'CLIENTS LEFT JOIN INVOCES on INVOICES.CLID = CLIENTS.CLID',

 

FORMAT lets you give format to the result, it is a CSV, where each value is assigned in the same order to the ones in RESULT, the number of comma separated values must be equal to the one in result

For example:

FORMAT = '<strong>COLNAME</strong>,<br/>COLNAME,<i>COLNAME</i>',

returns

FIRST RESULT,
SECOND RESULT, $THIRD RESULT

as for the CALLBACK, it will execute any javascript coded assigned here. also use equal instead of '='

 

 

Get a Quote

Get a Quote