Skip to content

Commit

Permalink
[open-formulieren/open-forms#3805] Fix label if field is not required
Browse files Browse the repository at this point in the history
Backport-of: #638
  • Loading branch information
Viicos authored and sergei-maertens committed Jan 26, 2024
1 parent 3daa5ba commit 7125428
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 83 deletions.
20 changes: 12 additions & 8 deletions src/components/forms/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ export const LabelContent = ({id, disabled = false, isRequired = false, type, ch
[`utrecht-form-label--${type}`]: type,
})}
>
<FormattedMessage
description="Form field label, field possibly optional"
defaultMessage="{withAsterisk, select, true {<label></label>} other {<label></label> (not required)}}"
values={{
withAsterisk: requiredFieldsWithAsterisk,
label: () => children,
}}
/>
{isRequired ? (
<>{children}</>
) : (
<FormattedMessage
description="Form field label, field not required"
defaultMessage="{withAsterisk, select, true {<label></label>} other {<label></label> (not required)}}"
values={{
withAsterisk: requiredFieldsWithAsterisk,
label: () => children,
}}
/>
)}
</FormLabel>
);
};
Expand Down
1 change: 0 additions & 1 deletion src/components/modals/FormStepSaveModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ const FormStepSaveModal = ({
values={{numberOfDays: suspendFormUrlLifetime}}
/>
</Body>

<EmailField
name="email"
isRequired
Expand Down
64 changes: 32 additions & 32 deletions src/i18n/compiled/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,38 @@
"value": "Payment"
}
],
"OnfuIr": [
{
"options": {
"other": {
"value": [
{
"children": [
],
"type": 8,
"value": "label"
},
{
"type": 0,
"value": " (not required)"
}
]
},
"true": {
"value": [
{
"children": [
],
"type": 8,
"value": "label"
}
]
}
},
"type": 5,
"value": "withAsterisk"
}
],
"P194bo": [
{
"type": 0,
Expand Down Expand Up @@ -1929,38 +1961,6 @@
"value": "Co-sign confirmation"
}
],
"yXbqL6": [
{
"options": {
"other": {
"value": [
{
"children": [
],
"type": 8,
"value": "label"
},
{
"type": 0,
"value": " (not required)"
}
]
},
"true": {
"value": [
{
"children": [
],
"type": 8,
"value": "label"
}
]
}
},
"type": 5,
"value": "withAsterisk"
}
],
"zQWnFh": [
{
"type": 0,
Expand Down
64 changes: 32 additions & 32 deletions src/i18n/compiled/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,38 @@
"value": "Betalen"
}
],
"OnfuIr": [
{
"options": {
"other": {
"value": [
{
"children": [
],
"type": 8,
"value": "label"
},
{
"type": 0,
"value": " (not required)"
}
]
},
"true": {
"value": [
{
"children": [
],
"type": 8,
"value": "label"
}
]
}
},
"type": 5,
"value": "withAsterisk"
}
],
"P194bo": [
{
"type": 0,
Expand Down Expand Up @@ -1933,38 +1965,6 @@
"value": "Bevestiging mede-ondertekening"
}
],
"yXbqL6": [
{
"options": {
"other": {
"value": [
{
"children": [
],
"type": 8,
"value": "label"
},
{
"type": 0,
"value": " (niet verplicht)"
}
]
},
"true": {
"value": [
{
"children": [
],
"type": 8,
"value": "label"
}
]
}
},
"type": 5,
"value": "withAsterisk"
}
],
"zQWnFh": [
{
"type": 0,
Expand Down
10 changes: 5 additions & 5 deletions src/i18n/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,11 @@
"description": "Payment page title",
"originalDefault": "Payment"
},
"OnfuIr": {
"defaultMessage": "{withAsterisk, select, true {<label></label>} other {<label></label> (not required)}}",
"description": "Form field label, field not required",
"originalDefault": "{withAsterisk, select, true {<label></label>} other {<label></label> (not required)}}"
},
"P194bo": {
"defaultMessage": "Invalid input: must start with \"{startsWith}\".",
"description": "ZOD 'invalid_string' error message, with startsWith",
Expand Down Expand Up @@ -879,11 +884,6 @@
"description": "On succesful completion title",
"originalDefault": "Co-sign confirmation"
},
"yXbqL6": {
"defaultMessage": "{withAsterisk, select, true {<label></label>} other {<label></label> (not required)}}",
"description": "Form field label, field possibly optional",
"originalDefault": "{withAsterisk, select, true {<label></label>} other {<label></label> (not required)}}"
},
"zQWnFh": {
"defaultMessage": "Are you sure that you want to logout and not co-sign the current form submission?",
"description": "log out confirmation prompt on co-sign page",
Expand Down
10 changes: 5 additions & 5 deletions src/i18n/messages/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,11 @@
"description": "Payment page title",
"originalDefault": "Payment"
},
"OnfuIr": {
"defaultMessage": "{withAsterisk, select, true {<label></label>} other {<label></label> (not required)}}",
"description": "Form field label, field not required",
"originalDefault": "{withAsterisk, select, true {<label></label>} other {<label></label> (niet verplicht)}}"
},
"P194bo": {
"defaultMessage": "De ingevoerde waarde moet beginnen met \"{startsWith}\".",
"description": "ZOD 'invalid_string' error message, with startsWith",
Expand Down Expand Up @@ -891,11 +896,6 @@
"description": "On succesful completion title",
"originalDefault": "Co-sign confirmation"
},
"yXbqL6": {
"defaultMessage": "{withAsterisk, select, true {<label></label>} other {<label></label> (niet verplicht)}}",
"description": "Form field label, field possibly optional",
"originalDefault": "{withAsterisk, select, true {<label></label>} other {<label></label> (not required)}}"
},
"zQWnFh": {
"defaultMessage": "Bent u zeker dat u wilt uitloggen en hiermee de inzending niet mede-ondertekent?",
"description": "log out confirmation prompt on co-sign page",
Expand Down

0 comments on commit 7125428

Please sign in to comment.