SugarCRM: How do I make "first name" and "salutation" required fields on the "Convert Lead to Contact" form? - sugarcrm

We use a customized installation of SugarCRM and I need to make a change to the "Convert Lead to Contact" form. On the form, only "last name" is marked as required, but if the user does not enter a salutation or first name, Sugar will throw an SQL error on the insert (because salutation and first name are required fields for contacts).
I've tried adding this line to "modules/Contacts/metadata/editviewdefs.php" and "modules/Contacts/metadata/quickcreatedefs.php":
array (
'name' => 'first_name',
'displayParams'=>array('required'=>true),
)
I'm trying other modifications but I can't find anything online yet on this exact problem. I will update this question with my findings. Thanks!
Update: Added "first_name" and "salutation" to the 'required_fields' array in "modules/Contacts/field_arrays.php", did not help.
Update: This is on SugarCRM 5.1. This work is happening during the upgrade to 5.1.
Update: Added the following line to "modules/Contacts/vardefs.php" the "email_and_name1" array, did not help.
'required' => 'true',

The above didn't work for me. I am using 5.2.0.
What worked for me was to edit custom/modules/{modulename}/metadata/editviewdefs.php and add:
'name' => 'first_name',
'displayParams' =>
array (
'required' => true,
),
Then quick repair/rebuild.

I appear to have figured out a solution. I created an upgrade file in "custom/Extension/modules/Contacts/Ext/Vardefs" called "custom.php". The contents of the file are below:
<?php
$dictionary['Contact']['fields']['salutation']['required'] = true;
$dictionary['Contact']['fields']['first_name']['required'] = true;
?>
After I did a "quick repair and rebuild", the salutation and first name were now required. This works for me.

Why not just make Fist Name and Salutation required fields in Leads? Then you can modify the fields to "required" right in Studio and not have to worry about upgrade security.

Related

SuiteCRM increase autocomplete time in EditView

I'm looking at a request from our customer to either lengthen the autofill or just remove it all together when adding an organisation in EditView.
e.g: https://demo.suiteondemand.com/index.php?module=Opportunities&action=EditView&return_module=Opportunities&return_action=DetailView
If you start typing into "Account Name" box 'A' it'll show all the Organisations starting with A but also it'll autofill the first result into the input box.
Is there a way to stop that autofill of the input box from happening or delay it?
Thanks
Edit: changed title to SuiteCRM
http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_6.5/Application_Framework/Quicksearch/
I used the Metadata example, and it worked.
[Edit]
To expand on the answer. If you want to remove autofill from any of the boxes you need to add the 'sqsNoAutofill' to achieve this you can do the following:
In a modules editviewdefs.php (e.g. modules/(module)/metadata/editviewdefs.php) locate the name of the input you wish to change e.g:
array (
'name' => 'assigned_user_name',
'label' => 'LBL_ASSIGNED_TO',
),
then add the following:
array (
'name' => 'assigned_user_name',
'label' => 'LBL_ASSIGNED_TO',
'displayParams' => array (
'class' => 'sqsEnabled sqsNoAutofill'
)
),
This will stop an input box with a quicksearch drop down from autofilling.
You can also make the change to the SugarField for Parent
include/SugarFields/Fields/Parent/EditView.tpl (line 51):
<input type="text" .... class="sqsEnabled sqsNoAutofill" .....>
I hope that helps someone else.

TYPO3 modify backend table

EDIT: TYPO3 version 4.7
there is table Create Website user with many tabs.
I am able to add new tab with my own data using:
$test = array(
'tx_promconf_send_email' => array(
'exclude' => 0,
'label' => 'HAHAHA',
'config' => array(
'type' => 'input'
,)));
t3lib_div::loadTCA('fe_users');
t3lib_extMgm::addTCAcolumns('fe_users',$test,1);
t3lib_extMgm::addToAllTCAtypes('fe_users','--div--;Documents;;;;1-1-1,tx_promconf_send_email');
But I am not able to put my input to already existing tabs. Also I was not able to find some explanation of this string 'fe_users','--div--;Documents;;;;1-1-1,tx_promconf_send_email'.
Is there an option how to modify existing tabs? Where can I found the name of the tab? I tried to use instead of --div-- name of the tab and it does not work.
This weird string is hardly documented. You can find the TCA Documentation here.
If you want to insert it to an existing tab, just do it by finding a field within the desired tab where you want to put your new field after or before.
For example:
t3lib_extMgm::addToAllTCAtypes('fe_users','tx_promconf_send_email', '', 'after:last_name');
Your field will now be displayed after the field "last_name", and so within the tab "Personal Data". You can also use "before:fieldname" to insert your field before a field.

HTML::FormHandler validate select

I'm using HTML::FormHandler to create some forms, and I'd like to be able to validate any select fields on the form by making sure that whatever value submitted was actually a value given to the user. Right now this is how I have my select field set up:
has_field 'choice' => (
type => 'Select',
label => 'Choice',
options => [{value=>"1",label=>"One"},{value=>"2"=>label=>"Two"}],
empty_select => '---Choose an Option---',
apply => [{
check => ['1','2'],
message => 'Must be a value in the list.',
}],
);
Right now this works, but I was wondering if there was a more elegant way to do it? Since HTML::FormHandler already knows what options it has for the field, is there any way to just tell HTML::FormHandler to validate that the what the user choice is in fact one of those options? I've looked through the documentation and can't seem to find it anywhere, but it seems like something that would make sense to have for a field with predefined values. Thanks!
According to the code for HTML::FormHandler::Field::Select this check is already done. Have you tried it?

"Repeated" group in Forms for password validation

I am using the 'repeated' field to validate a password in the form.
According to the documentation, the 'repeated' field group is supposed
to, render two identical fields (which it is doing) and submit only if
the values from both the fields match or it should throw a validation error. The
second part somehow does not seem to work. I tried using the example
code as is but, the form submits with no issue or error even if the
passwords do not match. Did anyone else come across the same issue or
is there something I am doing wrong?
I did not add a validation file nor do I use annotations. From what I understand from the documentation, the repeated filed checks the values from first_name and second_name fields automatically and submits the form only when both the values are equal which it is not doing. This is the code I am using,
->add('password', 'repeated',
array(
'type' => 'password',
)
)
This renders two fields 'First' and 'Second' and passes an array with the 'First' and 'Second' values on submit.
the correct syntax would be
->add('tmpPassword', 'repeated', array('type' => 'password'));
if you use the the same key for the field as for the type it can not assign the value correct.
It turns out it was a stupid mistake on my part. I was not validating the form in the controller. Once, I do that it works fine.

SugarCRM - How to add "More Info" icon that displays module "Description" field on mouseover

This is for SugarCRM v6.3
I need to add a "More Info" icon to the History subpanel, which, when moused-over, displays the relevant module's Description field, similar to how the More Info icon works in the Accounts ListView.
For starters I added new "History/metadata" folders to custom/modules/ and copied the subpaneldefs.php file from the core History/metadata folder.
In the subpaneldefs file, at the end of each of the module's column definitions, I added this as a test:
array ( 'customCode' => '<img src="themes/Sugar/images/info_inline.png"></img>', ),
That didn't seem to affect anything at all.
Not sure if it was just that I needed more than an image for the column to show, I then tried adding all of the code I thought was supposed to go there:
array (
'name' => 'nothing',
'module' => 'Notes',
'related_fields' => array ('id'),
'customCode' => '<a id="adspan_{$ID}" href="index.php?module=Notes&action=DetailView&record={$ID}" onmouseover="return SUGAR.util.getAdditionalDetails(\'Notes\',\'{$ID}\',\'adspan_{$ID}\');" onmouseout="return SUGAR.util.clearAdditionalDetailsCall()"><img src="themes/Sugar/images/info_inline.png"></img></a>'
),
This is, as you can see, intended for the Notes in the History subpanel, and I changed it accordingly for each of the other modules' column definitions in the subpaneldefs.php file. I modeled the code after some custom code I found that someone else here at work did for a dashlet, which shows details when an account name is moused over.
Unfortunately, that didn't work, either.
How do I accomplish this?
The only way to do this is by defining a new SugarWidget field for the field in question. Here's a good guide I found for it:
http://www.mediaart.lt/programming/sugarcrm-adding-custom-field-in-subpanel/