No it's no more hardcoded (hard code was to manage backward compatibility).
This is an example that may help you. Assume that your module is called
"cabinetmed" :
if (! isset($conf->cabinetmed->enabled))
$conf->cabinetmed->enabled=0; // This is to avoid warning
$this->dictionnaries=array(
'langs'=>'cabinetmed@cabinetmed',
'tabname'=>array(MAIN_DB_PREFIX."cabinetmed_diaglec",MAIN_DB_PREFIX."cabinetmed_examenprescrit",MAIN_DB_PREFIX."cabinetmed_motifcons"),
// List of tables we want dictonnary on
'tablib'=>array("DiagnostiqueLesionnel","ExamenPrescrit","MotifConsultation"),
// Label of
tables
'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label,
f.active FROM '.MAIN_DB_PREFIX.'cabinetmed_diaglec as f','SELECT f.rowid
as rowid, f.code, f.label, f.active FROM
'.MAIN_DB_PREFIX.'cabinetmed_examenprescrit as f','SELECT f.rowid as
rowid, f.code, f.label, f.active FROM
'.MAIN_DB_PREFIX.'cabinetmed_motifcons as f'), // Request to select
fields
'tabsqlsort'=>array("label ASC","label ASC","label
ASC"),
// Sort order
'tabfield'=>array("code,label","code,label","code,label"),
// List of fields (result of select to show dictionnary)
'tabfieldvalue'=>array("code,label","code,label","code,label"),
// List of fields (list of fields to edit a record)
'tabfieldinsert'=>array("code,label","code,label","code,label"),
//
List of fields (list of fields for insert)
'tabrowid'=>array("rowid","rowid","rowid"),
// Name of columns with primary key (try to always name it
'rowid')
'tabcond'=>array($conf->cabinetmed->enabled,$conf->cabinetmed->enabled,$conf->cabinetmed->enabled)
// Condition to show each
dictionnary
);
Le 18/10/2011 03:57, Remy Younes a écrit :
Hello everyone,
I noticed that modules can now add dictionaries by
setting $this->dictionnaries = array(); in the module descriptor (in
3.2 dev, maybe earlier but I wasn't aware).
This is a nice feature, however I can't figure out how to define the
input type for each field.
I see that this is hardcoded in dict.php in the fieldList method
for example, for country selection we have:
if ($fieldlist[$field] == 'pays') {
if (in_array('region_id',$fieldlist)) { print
'<td> </td>'; continue; }// For region page, we do not show the
country input
print '<td>';
$html->select_pays($obj->pays,'pays');
print '</td>';
}
It would be nice to be able to define our own fields' types as well
Maybe the use of hooks or triggers would be appropriate.
Let me know if i'm missing something. Otherwise, I have some code that
I wrote under dol v2.9 that I could share.
_______________________________________________
Dolibarr-dev mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/dolibarr-dev
--
Eldy (Laurent Destailleur).
---------------------------------------------------------------
EMail: [email protected]
Web: http://www.destailleur.fr
Dolibarr (Project leader): http://www.dolibarr.org
To make a donation for Dolibarr project via Paypal: [email protected]
AWStats (Author) : http://awstats.sourceforge.net
To make a donation for AWStats project via Paypal: [email protected]
AWBot (Author) : http://awbot.sourceforge.net
CVSChangeLogBuilder (Author) : http://cvschangelogb.sourceforge.net
_______________________________________________
Dolibarr-dev mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/dolibarr-dev