[Vtigercrm-developers] Develop New Module
Alan Lord
alanslists at gmail.com
Thu Oct 10 07:09:40 UTC 2013
On 09/10/13 23:26, Pabiszczak, Błażej wrote:
> If we need create many fields we install module and use Layout Editor.
Gosh - That's rather slow and cumbersome.
I find it much faster and more repeatable to create all your fields via
a vtlib script:
> // Meter ID
> $field = Vtiger_Field::getInstance('meterid', $module);
> if ($field != false) {
> $field->delete();
> }
> $field = new Vtiger_Field();
> $field->name = 'meterid';
> $field->label = 'LBL LSMETER ID';
> $field->column = 'meterid';
> $field->columntype = 'VARCHAR(255)';
> $field->uitype = 1;
> $field->typeofdata = 'V~O';
> $block_main->addField($field);
> unset($field);
>
> //Supplier
> $field = Vtiger_Field::getInstance('relvendorid', $module);
> if ($field != false) {
> $field->unsetRelatedModules(Array('Vendors'));
> $field->delete();
> }
> $field = new Vtiger_Field();
> $field->name = 'relvendorid';
> $field->column = 'relvendorid';
> $field->label = 'LSSUPPLIER';
> $field->columntype = 'INT(11)';
> $field->uitype = 10;
> $field->typeofdata = 'V~M';
> $block_main->addField($field);
> $field->setRelatedModules(Array('Vendors'));
> unset($field);
(Once you've written one it just a search and replace to create fields
with different names etc.)
This kind of script can be run over and over again - tweaking things as
and when necessary.
> When we export module, we change table name (without cf) and add special
> fields (like UIType 10).
No need to rename tables using vtlib. We now start all our own custom
modules with libertus_...
One thing that would be helpful would be an API to be able to do that
for the custom picklist tables too...
Cheers
Al
More information about the vtigercrm-developers
mailing list