Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX #7912 - Avoid PHP Notices in getVardefs() method #7913



Copy link

Abuelodelanada commented Sep 23, 2019


Read #7912

Motivation and Context

Avoid annoying PHP Notices in php log

How To Test This

  1. Define a Float field in a subpanel
  2. Check for Notices in PHP log

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Final checklist

  • My code follows the code style of this project found here.
  • My change requires a change to the documentation.
  • I have read the How to Contribute guidelines.

This comment has been minimized.

Copy link

Mac-Rae commented Sep 25, 2019

Hey @Abuelodelanada,

I've been unable to replicate the error in the logs. Could you confirm;
Where you just on the detail view with the subpanel containing the float open?
Did you have to interact with the record or value?
And im using the Amount field on Opportunities for testing. What did you use?

Thanks 👍


This comment has been minimized.

Copy link
Contributor Author

Abuelodelanada commented Sep 25, 2019

Hi @Mac-Rae

With this PR we only make sure that $layout_def['column_key'] and $this->layout_manager->defs['reporter'] are set, before using it.
And it improves the possibility that SuiteCRM is extended without PHP notices in the log.

We have a custom SugarWidgetField that inherits from SugarWidgetFieldFloat called SugarWidgetFieldFloatD. (The D is for Decorated ;-) )

We created this field to align float numbers to the right and add other specific CSS classes, not big deal.

This fix is simple as you can see, but to reproduce the bug it's a little complex:

  1. Create a custom widget like this in include/generic/SugarWidgets/SugarWidgetFieldFloatD.php:
class SugarWidgetFieldFloatD extends SugarWidgetFieldFloat
    public function displayList(&$layout_def)
        return parent::displayList($layout_def);

This is a simplification of what we have, but in displayList function you can add CSS for example taken from subpanel definition for example.

  1. In the subpanel definition of the module you have to add the following:
'widget_class' => 'FieldFloatD',

In our instance we have:

        'saldoDeudorPesos' => array(
            'vname' => 'LBL_SALDODEUDORPESOS',
            'width' => '20%',
            'default' => true,
            'sortable' => false,
            'widget_class' => 'FieldFloatD',
            'style' => array(

You can do the same in: modules/Opportunities/metadata/subpanels/ForAccounts.php

            'vname' => 'LBL_LIST_AMOUNT_USDOLLAR',
            'width' => '15%',
            'widget_class' => 'FieldFloatD',
  1. Just to test this fix, in the Opportunities vardefs.php you should have the amount_usdollar like this:
        'amount_usdollar' =>
                'name' => 'amount_usdollar',
                'vname' => 'LBL_AMOUNT_USDOLLAR',
                'type' => 'floatd',
                'group' => 'amount',
                'dbType' => 'double',
                'disable_num_format' => true,
                'duplicate_merge' => '0',
                'audited' => true,
                'comment' => 'Formatted amount of the opportunity',
                'studio' => array(
                    'editview' => false,
                    'detailview' => false,
                    'quickcreate' => false,
  1. Quick Repair and Rebuild.

  2. Reload an Account DetailView with a created opportunity in subpanel.

  3. Check PHP log. You will not see the PHP Notices.

  4. If you do the same without this fix you will see the Notices in the log


This comment has been minimized.

Copy link
Contributor Author

Abuelodelanada commented Oct 2, 2019

Hi @Mac-Rae

Could you read how to test this PR?


This comment has been minimized.

Copy link

Mac-Rae commented Oct 3, 2019

Sorry for the wait, I missed the notification that you had replied. Looks good to me 👍

@Mac-Rae Mac-Rae added the Assessed label Oct 3, 2019
@Dillon-Brown Dillon-Brown merged commit af66886 into salesagility:hotfix-7.10.x Oct 3, 2019
3 checks passed
3 checks passed
Codacy/PR Quality Review Up to standards. A positive pull request.
clahub All contributors have signed the Contributor License Agreement.
continuous-integration/travis-ci/pr The Travis CI build passed
@Abuelodelanada Abuelodelanada deleted the gcoop-libre:hotfix-7.10.x-7912 branch Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.