Adding functionality for setting your own names for vtiger custom field

Adding functionality for setting your own names for vtiger custom field

Vtiger CRM gives us an excellent opportunity to  create fields quickly and easily in any module. But there is a catch with this approach.

In the field editor, you can set the field title, even its length, but when creating a field, the system assigns a name to the newly created field automatically, and the name will be completely unreadable, such as cf_997. Where cf is abbreviated "Custom Field", and 997 is the number of the new field.

And this is not at all convenient for development or for API integration. If you create only one field, then that's okay. And if there are a lot of custom fields, then such a variety of numbers turns into a nightmare.

You will simply be forced to check the base of what your field is called to insert its number into the code. But what if instead of a number there will be some clear text. For example, cf_friend_name. Agree, this is much more convenient and easier to support?

Below I offer some recommendations for changing the field editor so that you can set your own name for the field. To do this, you will need basic programming knowledge and make adjustments to 4 files.

At first we need to change file layouts/v7/modules/Settings/LayoutEditor/FieldCreate.tpl, near 77.

Under this line:


Add following:

<div class="form-group">

                            <label class="control-label fieldLabel col-sm-5">

                                {vtranslate('Field Name', $QUALIFIED_MODULE)}

                                &nbsp;<span class="redColor">*</span>


                            <div class="controls col-sm-7">

                                <input type="text" class='inputElement col-sm-9' maxlength="50" {if $IS_FIELD_EDIT_MODE}disabled="disabled"{/if} name="fieldName" value="{vtranslate($FIELD_MODEL->get('label'), $SELECTED_MODULE_NAME)}" data-rule-alphanumeric='true' style='width: 75%' />




Next change file modules/Settings/LayoutEditor/models/Module.php near str 146

Change lines:

$max_fieldid = $db->getUniqueID("vtiger_field");

$columnName = 'cf_'.$max_fieldid;

$custfld_fieldid = $max_fieldid;

To this lines:


    $columnName = 'cf_'.$params['fieldName'];




$max_fieldid = $db->getUniqueID("vtiger_field");

$columnName = 'cf_'.$max_fieldid;

$custfld_fieldid = $max_fieldid;



Then we need to add some kind of validation so that the system accepts only numbers and letters, as well as a lower-case character. Columns in the database are created with the same name as the field name. Therefore, without validation there is nowhere.

layouts/v7/modules/Settings/LayoutEditor/resources/LayoutEditor.js on line 854,

Under this line:

form.find('[name="fieldLabel"]').attr('data-rule-illegal', "true");

add this lines:

form.find('[name="fieldName"]').attr('data-rule-alphanumeric', "true");

layouts/v7/modules/Vtiger/resources/validation.js на строке 22 добавляем:

jQuery.validator.addMethod("alphanumeric", function(value, element, params) {


var regex = /^[a-z0-9_]+$/g;


return false;



return true;

}, jQuery.validator.format("Small Letters, numbers, and underscores only please"));


So, now when you write in the friendname field, the system will create a new field called cf_friendname. Those. prefix cf_ will be added before the field name

This is a system prefix that says the field was created manually and can be safely removed from CRM.

If you do not fill out the field, then everything will go as usual and the name will be created automatically from the numbers.

Popular Posts

My most popular posts

Maximum productivity on remote job

Maximum productivity on remote job

I started my own business and intentionally did my best to work from anywhere in the world. Sometimes I sit with my office with a large 27-inch monitor in my apartment in Cheboksary. Sometimes I’m in the office or in some cafe in another city.

Hello! I am Sergey Emelyanov and I am hardworker
Business PHP

Hello! I am Sergey Emelyanov and I am hardworker

I am a programmer. I am an entrepreneur in my heart. I started making money from the age of 11, in the harsh 90s, handing over glassware to a local store and exchanging it for sweets. I earned so much that was enough for various snacks.

Hire Professional CRM developer for $25 per hour

I will make time for your project. Knowledge of Vtiger CRM, SuiteCRM, Laravel, and Vue.js. I offer cooperation options that will help you take advantage of external experience, optimize costs and reduce risks. Full transparency of all stages of work and accounting for time costs. Pay only development working hours after accepting the task. Accept PayPal and Payoneer payment systems. How to hire professional developer? Just fill in the form