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…
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
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.
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.