Hi ZZ
Have you tried this? I hope this helps
https://gregwiechec.com/2018/03/hide-tabs-and-properties-in-edit-mode/
I have tried but it doesn't work. I am trying to use this link to create custom attribute https://docs.developers.optimizely.com/content-management-system/docs/writing-custom-attributes
but having difficulty to get the value of the property in CreateDisplayMetadata ()
public class HideFieldAttribute : ValidationAttribute, IDisplayMetadataProvider
{
private readonly string _fieldName;
public HideFieldAttribute(string fieldName)
{
_fieldName = fieldName;
}
public void CreateDisplayMetadata(DisplayMetadataProviderContext context)
{
// get value of the property ??
throw new NotImplementedException();
}
}
Hi ZZ
I see you tried to roll out your own implementation with the dev doc, but your requirement is more complex and just implement a custom attribute would not be sufficient, because of this reason I suggested the package above.
P.S. The package I mentioned earlier does exact what you need. I used in other projects in the past, and worked like a charm. In addition, it's open source, if you really keen to do your own implementation, check out the source to see what might be required.
Whats the name of the NuGet package and is this compatible with CMS 12.17.x ?
Package is called Alloy.HideTabs --
It is compatible with CMS 12, yes.
Another approach to showing/hiding properties based on another property's value can be found here:
https://www.codeart.dk/blog/2022/11/property-dependency-in-optimizely-episerver-cms-12/
Hi,
Is it possible to hide/show block properties based on someother block, Lets say I have string property in a block and I want to hide it in a block based on another boolean property in the same block. Is that possible in CMS 12. ?