CoreBOSBB
Creating a dropdown from vtlib - Printable Version

+- CoreBOSBB (https://discussions.corebos.org)
+-- Forum: Support (https://discussions.corebos.org/forumdisplay.php?fid=17)
+--- Forum: Modules/Extension Support (https://discussions.corebos.org/forumdisplay.php?fid=9)
+--- Thread: Creating a dropdown from vtlib (/showthread.php?tid=211)



Creating a dropdown from vtlib - Guido1982 - 12-02-2015

For my ExactOnline module, I'm in the process of syncing the general ledgers to coreBOS from Exact. I created a dropdown in products like this:
PHP Code:
$Vtiger_Utils_Log true;
 include_once(
'vtlib/Vtiger/Menu.php');
 include_once(
'vtlib/Vtiger/Module.php');
 
$module Vtiger_Module::getInstance('Products');
 
$infoBlock Vtiger_Block::getInstance('LBL_PRODUCT_INFORMATION'$module);
 
$glaccountsField Vtiger_Field::getInstance('generalledgers'$module);
 if (!
$glaccountsField) {
 
$glaccountsField = new Vtiger_Field();
 
$glaccountsField->name 'generalledgers';
 
$glaccountsField->label 'General Ledger Accounts';
 
$glaccountsField->column 'generalledgers';
 
$glaccountsField->columntype 'VARCHAR(255)';
 
$glaccountsField->uitype 16;
 
$glaccountsField->typeofdata 'V~M';
 
$glaccountsField->setPicklistValues($GLAccountValues);
 
$infoBlock->addField($glaccountsField);
 } 

This works, but does produce errors, what am I doing wrong? Here are the errors:


PHP Code:
Strict StandardsOnly variables should be assigned by reference in /PATH/crmdevelop/include/database/PearDatabase.php on line 225
Creating table vtiger_generalledgers 
... DONE

Strict Standards
Only variables should be assigned by reference in /PATH/crmdevelop/include/database/PearDatabase.php on line 225

Strict Standards
Only variables should be assigned by reference in /PATH/crmdevelop/include/database/PearDatabase.php on line 225

Strict Standards
Only variables should be assigned by reference in /PATH/crmdevelop/include/database/PearDatabase.php on line 225
Creating Field generalledgers 
... DONE
Module language mapping 
for General Ledger Accounts ... CHECK

Catchable fatal error
Object of class Vtiger_Module could not be converted to string in /PATH/index.php on line 687 



RE: Creating a dropdown from vtlib - joebordes - 12-02-2015

The "Strict Standard" are normal. I am freneticly eliminating those as I can and will eventually get to PearDatabase. In the mean time, set your PHP error_reporting variable to ignore strict and warning. I usually set it to:

error_reporting=E_ERROR

The Fatal error is another thing but that is related to your particular index.php file. What code do you have on that line?

BTW, the vtlib field creation script looks ok


RE: Creating a dropdown from vtlib - Guido1982 - 12-02-2015

I replaced all paths that would reveal my actual one with the word PATH, but the index file (if I remember correctly) pointed to the index file of coreBOS. I have to repeat this for Service so I'll double check.

I was wondering, isn't it possible for two modules to use the same dropdown? Seems kind of redundant to make the same table twice (and also need to update it periodically), since the values are stored per line anyway.

(12-02-2015, 06:12 PM)joebordes Wrote: The Fatal error is another thing but that is related to your particular index.php file. What code do you have on that line?

Just checked, the error is definitely in the main index.php of coreBOS. The field is created and filled with the values I collect from Exact though.


RE: Creating a dropdown from vtlib - joebordes - 12-02-2015

Yes, you can have shared picklist, you just have to use the same fieldname

index.php line 687 is a comment:
https://github.com/tsolucio/corebos/blob/master/index.php#L687

that won't produce an error, much less a fatal one.


RE: Creating a dropdown from vtlib - Guido1982 - 12-02-2015

That's weird. I double, triple checked, but maybe this is because some includes cause the line numbers to be screwed up.