From e27523fea11fbdf7cf58bf9479ff0bfbebf303ae Mon Sep 17 00:00:00 2001 From: sunnavy Date: Fri, 3 Nov 2023 13:27:24 -0400 Subject: [PATCH] Add required attribute for mandatory custom field inputs The attribute isn't enabled for radio/checkbox inputs. "(no value)" passes the "required" limitation for radio, which makes it useless. For checkbox, "required" indicates all "required" checkbox inputs(even with the same name) must be checked, which is not what want either. --- share/html/Admin/CustomFields/Modify.html | 2 +- share/html/Admin/Queues/DefaultValues.html | 5 +++++ share/html/Elements/EditCustomField | 1 + share/html/Elements/EditCustomFieldAutocomplete | 10 +++++++++- share/html/Elements/EditCustomFieldBinary | 7 ++++++- share/html/Elements/EditCustomFieldCombobox | 2 ++ share/html/Elements/EditCustomFieldDate | 3 ++- share/html/Elements/EditCustomFieldDateTime | 3 ++- share/html/Elements/EditCustomFieldFreeform | 7 +++++++ share/html/Elements/EditCustomFieldHTML | 4 ++++ share/html/Elements/EditCustomFieldImage | 7 ++++++- share/html/Elements/EditCustomFieldSelect | 4 ++++ share/html/Elements/EditCustomFieldText | 4 ++++ share/html/Elements/EditCustomFieldWikitext | 4 ++++ share/html/Elements/EditCustomFields | 1 + share/html/Elements/SelectDate | 4 ++++ share/html/Widgets/ComboBox | 3 ++- 17 files changed, 64 insertions(+), 7 deletions(-) diff --git a/share/html/Admin/CustomFields/Modify.html b/share/html/Admin/CustomFields/Modify.html index beee4675a0c..180966fad6a 100644 --- a/share/html/Admin/CustomFields/Modify.html +++ b/share/html/Admin/CustomFields/Modify.html @@ -181,7 +181,7 @@ % if ( $CustomFieldObj->SupportDefaultValues ) { <&| /Elements/LabeledValue, Label => loc("Default [numerate,_1,value,values]", $CustomFieldObj->MaxValues), Class => $default_value_class &> - <& /Elements/EditCustomField, NamePrefix => 'Default-', CustomField => $CustomFieldObj, ShowEmptyOption => 1 &> + <& /Elements/EditCustomField, NamePrefix => 'Default-', CustomField => $CustomFieldObj, ShowEmptyOption => 1, Required => 0 &> % } diff --git a/share/html/Admin/Queues/DefaultValues.html b/share/html/Admin/Queues/DefaultValues.html index 0cde0c46ddd..dca52fa81ac 100644 --- a/share/html/Admin/Queues/DefaultValues.html +++ b/share/html/Admin/Queues/DefaultValues.html @@ -68,6 +68,7 @@ CustomFields => $queue->TicketCustomFields->LimitToDefaultValuesSupportedTypes, Grouping => 'Basics', CategoryObj => $queue, + Required => 0, &> <&| /Elements/LabeledValue, Label => loc('Article') &> @@ -91,6 +92,7 @@ CustomFields => $queue->TicketCustomFields->LimitToDefaultValuesSupportedTypes, Grouping => 'Dates', CategoryObj => $queue, + Required => 0, &> @@ -103,6 +105,7 @@ CustomFields => $queue->TicketCustomFields->LimitToDefaultValuesSupportedTypes, Grouping => 'People', CategoryObj => $queue, + Required => 0, &> @@ -116,6 +119,7 @@ CustomFields => $queue->TicketCustomFields->LimitToDefaultValuesSupportedTypes, Grouping => 'Links', CategoryObj => $queue, + Required => 0, &> @@ -126,6 +130,7 @@ Object => RT::Ticket->new($session{CurrentUser}), Groupings => \@groupings, CategoryObj => $queue, + Required => 0, &>
diff --git a/share/html/Elements/EditCustomField b/share/html/Elements/EditCustomField index c088917ee70..b2e75720642 100644 --- a/share/html/Elements/EditCustomField +++ b/share/html/Elements/EditCustomField @@ -162,4 +162,5 @@ $Rows => 5 $Cols => 15 $Default => undef $DefaultsFromTopArguments => 1, +$Required => undef diff --git a/share/html/Elements/EditCustomFieldAutocomplete b/share/html/Elements/EditCustomFieldAutocomplete index 40104555ae7..2acef923d7c 100644 --- a/share/html/Elements/EditCustomFieldAutocomplete +++ b/share/html/Elements/EditCustomFieldAutocomplete @@ -53,6 +53,9 @@ cols="<% $Cols %>" \ % if ( defined $Rows ) { rows="<% $Rows %>" \ % } +% if ( $Required ) { +required +% } name="<% $name %>" id="<% $name %>" class="CF-<%$CustomField->id%>-Edit form-control"><% $Default || '' %>