配置 DateTimeDropdown 年份选择
Configuring DateTimeDropdown year selection
我有一个带有 DateTimeDropdown
声明类型的注册表,允许用户 select 他们的出生日期。
这是声明的策略配置:
<ClaimType Id="dateOfBirth">
<DisplayName>Date of birth</DisplayName>
<DataType>date</DataType>
<UserHelpText>Please select your birth date</UserHelpText>
<UserInputType>DateTimeDropdown</UserInputType>
</ClaimType>
以及它在表单上的呈现方式:
Year
selection 给出了从 1900 开始到 2050 的范围。
是否有任何自定义策略配置来更改、限制或重新排序此下拉列表中的值?
现在可以通过使用 PredicateValidations 来实现。参见 date range
使用 Predicates 和 PredicateValidations 元素,您可以使用 DateTimeDropdown
控制 UserInputType 的最小和最大日期值
<Predicates>
<Predicate Id="DateRange" Method="IsDateRange" HelpText="The date must be between 01-01-1980 and today.">
<Parameters>
<Parameter Id="Minimum">1980-01-01</Parameter>
<Parameter Id="Maximum">Today</Parameter>
</Parameters>
</Predicate>
</Predicates>
添加一个引用 DateRange 谓词的 PredicateValidation。
<PredicateValidations>
<PredicateValidation Id="CustomDateRange">
<PredicateGroups>
<PredicateGroup Id="DateRangeGroup">
<PredicateReferences>
<PredicateReference Id="DateRange" />
</PredicateReferences>
</PredicateGroup>
</PredicateGroups>
</PredicateValidation>
</PredicateValidations>
在您的声明类型中,添加 PredicateValidationReference 元素并将标识符指定为 CustomDateRange。
<ClaimType Id="dateOfBirth">
<DisplayName>Date of Birth</DisplayName>
<DataType>date</DataType>
<AdminHelpText>The user's date of birth.</AdminHelpText>
<UserHelpText>Your date of birth.</UserHelpText>
<UserInputType>DateTimeDropdown</UserInputType>
<PredicateValidationReference Id="CustomDateRange" />
</ClaimType>
我有一个带有 DateTimeDropdown
声明类型的注册表,允许用户 select 他们的出生日期。
这是声明的策略配置:
<ClaimType Id="dateOfBirth">
<DisplayName>Date of birth</DisplayName>
<DataType>date</DataType>
<UserHelpText>Please select your birth date</UserHelpText>
<UserInputType>DateTimeDropdown</UserInputType>
</ClaimType>
以及它在表单上的呈现方式:
Year
selection 给出了从 1900 开始到 2050 的范围。
是否有任何自定义策略配置来更改、限制或重新排序此下拉列表中的值?
现在可以通过使用 PredicateValidations 来实现。参见 date range
使用 Predicates 和 PredicateValidations 元素,您可以使用 DateTimeDropdown
控制 UserInputType 的最小和最大日期值<Predicates> <Predicate Id="DateRange" Method="IsDateRange" HelpText="The date must be between 01-01-1980 and today."> <Parameters> <Parameter Id="Minimum">1980-01-01</Parameter> <Parameter Id="Maximum">Today</Parameter> </Parameters> </Predicate> </Predicates>
添加一个引用 DateRange 谓词的 PredicateValidation。
<PredicateValidations> <PredicateValidation Id="CustomDateRange"> <PredicateGroups> <PredicateGroup Id="DateRangeGroup"> <PredicateReferences> <PredicateReference Id="DateRange" /> </PredicateReferences> </PredicateGroup> </PredicateGroups> </PredicateValidation> </PredicateValidations>
在您的声明类型中,添加 PredicateValidationReference 元素并将标识符指定为 CustomDateRange。
<ClaimType Id="dateOfBirth"> <DisplayName>Date of Birth</DisplayName> <DataType>date</DataType> <AdminHelpText>The user's date of birth.</AdminHelpText> <UserHelpText>Your date of birth.</UserHelpText> <UserInputType>DateTimeDropdown</UserInputType> <PredicateValidationReference Id="CustomDateRange" /> </ClaimType>