I have never tried to do this, I believe it is possible but it could cause errors when saving. You're probably not getting it because of the variations.
I don't know if it will work, but following the documentation it would be this:
public void Handle(SendingContentNotification notification)
{
foreach (var variant in notification.Content.Variants)
{
//ContentSavedStateaccording to your needs
if (variant.State == ContentSavedState.NotCreated)
{
foreach (var property in variant.Tabs.SelectMany(f => f.Properties))
{
if (property.Alias == "title")
{
_logger.LogInformation($"Changing property editor for {property.Alias} to TextArea");
property.PropertyEditorAlias = "Umbraco.TextArea";
}
}
}
}
}
Change field's PropertyEditor in SendingContentNotification handler
I have GenericPage content type, it has Title property (TextBox).
In SendingContentNotification, I'd like to change it to TextArea data type (based on parent document type).
Is it possible to change property PropertyEditor value in the SendingContentNotification?
I have tried to change it via PropertyEditorAlias but it does not work...
public void Handle(SendingContentNotification notification) { foreach (var property in notification.Content.Properties) { if (property.Alias == "title") { _logger.LogInformation($"Changing property editor for {property.Alias} to TextArea"); property.PropertyEditorAlias = "Umbraco.TextArea"; } } }
I have never tried to do this, I believe it is possible but it could cause errors when saving. You're probably not getting it because of the variations.
I don't know if it will work, but following the documentation it would be this:
https://docs.umbraco.com/umbraco-cms/reference/notifications/editormodel-notifications
Wouldn't it be possible for the field to already be a TextArea?
is working on a reply...