Vulnerability in EPiServer.Forms
How can I hide a property when creating a block, but showing the property on edit mode?
Also, is there a create content event? In that event, I want to set a property based on another property's value.
To clarify, there is no preview mode for this block.
If you are using form I think you can set the Editable attribute on the EPiServer:Property control that renders the property.
Using [Editable(false)] will make the the property not editable neither on create mode nor edit mode. It's only when creating the block I want to hide the property.
Sorry I missed that your block didn't have anya preview mode.
If the property appears during block creation it's probably annotated with Required attribute. All properties with this attribute will be shown.
You could create you own validation rule (IValidate<T>), where you will check if the value is filled, but also if the PageLink.WorkId is not zero (it will be 0 for new pages). Then the required rule will be checked only during editing and the property won't be displayed in block craeting.
About second part of your question. You can subscribe to create event using code:
var contentEvents = ServiceLocator.Current.GetInstance<IContentEvents>();//contentEvents.CreatingContent += ... //contentEvents.CreatingContent += ...