Vulnerability in EPiServer.Forms
I have created Required property which I used to set value for a different property during page creation.
Now I want to remove/hide/ignore this required property after content creation.
I am unable to change the metadata of this property in the content creation event.
You can hide the property using below method-
and if you want to remove it permanently then you can delete it from code and then remove it from CMS->Admin->ContentType->Your Block/Page->Your property and remove it.
I think that, to do what you want, you'll need to create a custom validator which is sets your field as required when the value is not set then hides the field from the editor once it's set. You can do that like this:
public class InitialValidator : ValidationAttribute, IMetadataAware
public void OnMetadataCreated(ModelMetadata metadata)
var contentMetadata = metadata as ContentDataMetadata;
if (contentMetadata.InitialValue != null)
metadata.IsRequired = false;
metadata.ShowForEdit = false;
metadata.IsRequired = true;
Which you could then apply just by adding a [InitialValidator] attribute to the property which you only want to show on creation.