Field display logic

 1 => 
          array (
            'name' => 'submissionduedate_c',
            'label' => 'LBL_SUBMISSIONDUEDATE',
             'displayLogic' => [
                    'hide_on_extension_flag_c' => [
                    'key' => 'displayType',
                    'modes' => [
                        'detail',
                        'edit',
                         'create',
                         ],
          'params' => [
              'fieldDependencies' => [
                  'extensionflag_c',
              ],
              'targetDisplayType' => 'none',
              'activeOnFields' => [
                  'extensionflag_c' => ['false'],
              ]
          ]
      ]
             ]
          ),

how to make it by default hidden

'display' => 'none',

can be added to field definition in detailviewdefs.php OR vardefs

Where exactly do you suggest to add this?

@hserour if you tried it and it worked, please provide some feedback here with details, and mark that post as “solution”

before display logic

1 Like

This article says you’re supposed to used 'display' => 'hide' (instead of 'none'), although it’s for panels, not fields - I am not sure if this should be the same…

Nice :smile:

  array(
          0 =>
          array(
            'name' => 'case_number',
            'label' => 'LBL_CASE_NUMBER',
          ),
          1 =>
          [
            'name' => 'priority',
            'display' => 'none',
            'logic' => [
                'calculate-priority-display' => [
                    'key' => 'displayTypeBackend',
                    'modes' => ['detail', 'edit', 'create'],
                    'params' => [
                        'fieldDependencies' => [
                            'type',
                            'name',
                        ],
                        'process' => 'calculate-priority-display',
                        'activeOnFields' => [
                            'type' => ['User'],
                            'name' => [
                                ['operator' => 'not-empty' ]
                            ]
                        ]
                    ]
                ],
          ],
        ),

Did anybody try this with the panels? I find this incongruity between ‘hide’ and ‘none’ annoying, and potentially misleading…

Hi there,

I’ve just tried this approach with panels and it works well. By default my panels are hidden, they show up when an enum field gets a specific value.
But the problem with this approach is that it has to be done in the file public/legacy/custom/modules/<module>/metadata/detailviewdefs.php, which is completely rebuilt each time you change something on the detail/edit view through the Studio :thinking:

So I tried to set it through public/legacy/custom/Extension/modules/<module>/Ext/Layoutdefs/detailviewdefs.php (coming from SugarCRM world), but it looks like it’s not working.

May I miss something? Because if this kind of customization is wiped out each time you go to the Studio, it looks useless to me…

If you pay attention to the examples in those blog posts, they’re not editing files directly, they’re injecting elements into arrays dynamically. Try it that way.

1 Like

Hi @pgr ,

Thank you for taking the time to answer.
I’ve tried it that way but it doesn’t work. When editing the view in the Studio it looks like the entire file is replaced with the new content. This behaviour is confirmed with what I see in the code (method _saveToFile in file public/legacy/modules/ModuleBuilder/parsers/views/AbstractMetaDataImplementation.php).

@sgr , I just tried to test this by adding some logic in the detailviewdefs.php and made some changed on detail view layout from the studio, The previous array elements and logic were not replaced after quick repair & rebuild. This is working fine as @pgr said.

If you don’t want to change the detailviewdefs.php ,you can use view definition mappers which adds/modifies array elements dynamically without changing the metadata file. You can refer the code in the following example.