Skip to content

Nullable enum extension property is not rendered as a dropdown #24185

@Ahmedrz89

Description

@Ahmedrz89

Is there an existing issue for this?

  • I have searched the existing issues

Description

Abp version 9.3.2
mvc razor pages

when adding a new extension property to identity user and the property type is a nullable enum the generated input in the add or edit user is not rendered as a dropdown but rather an input field and based on the documentation nullable enums should be a dropdown with an empty item added automatically.

ObjectExtensionManager.Instance.Modules()
.ConfigureIdentity(identity =>
{
identity.ConfigureUser(user =>
{
user.AddOrUpdateProperty<UserType?>(
"UserType"
);
});
});

and it is not related to user only but rather any nullable enum auto generated by this code which is used on all edit and add cshml pages

@foreach (var propertyInfo in await ObjectExtensionManager.Instance.GetPropertiesAndCheckPolicyAsync<EditModalModel.UserInfoViewModel>(HttpContext.RequestServices))
{
if (!propertyInfo.Name.EndsWith("_Text"))
{
if (propertyInfo.Type.IsEnum || !propertyInfo.Lookup.Url.IsNullOrEmpty())
{
if (propertyInfo.Type.IsEnum)
{
Model.UserInfo.ExtraProperties.ToEnum(propertyInfo.Name, propertyInfo.Type);
}
<abp-select asp-for="UserInfo.ExtraProperties[propertyInfo.Name]"
label="@propertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)"
autocomplete-api-url="@propertyInfo.Lookup.Url"
autocomplete-selected-item-name="@Model.UserInfo.GetProperty(propertyInfo.Name+"_Text")"
autocomplete-selected-item-value="@Model.UserInfo.GetProperty(propertyInfo.Name)"
autocomplete-filter-param-name="@propertyInfo.Lookup.FilterParamName"
autocomplete-items-property-name="@propertyInfo.Lookup.ResultListPropertyName"
autocomplete-display-property-name="@propertyInfo.Lookup.DisplayPropertyName"
autocomplete-value-property-name="@propertyInfo.Lookup.ValuePropertyName">
}
else
{

}
}
}

basically propertyInfo.Type.IsEnum this will return false for the nullable property

is there a workaround for this rather than overriding all these pages?

Image

Reproduction Steps

No response

Expected behavior

nullable enum extension properties to be rendered as a dropdown with an empty item

Actual behavior

nullable enum extension properties are rendered as a regular input

Regression?

No response

Known Workarounds

overriding all the pages that should render this new extension property

Version

9.3.2

User Interface

MVC

Database Provider

EF Core (Default)

Tiered or separate authentication server

Tiered

Operation System

Windows (Default)

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions