Skip to content

Commit 89f80d6

Browse files
committed
subcommunity: updated error mapping in the ui
1 parent 9a8786f commit 89f80d6

File tree

1 file changed

+10
-3
lines changed
  • invenio_communities/assets/semantic-ui/js/invenio_communities/subcommunity

1 file changed

+10
-3
lines changed

invenio_communities/assets/semantic-ui/js/invenio_communities/subcommunity/new.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const IdentifierField = ({ formConfig }) => {
3535
"This is your community's unique identifier. You will be able to access your community through the URL:"
3636
)}
3737
<br />
38-
{`${formConfig.SITE_UI_URL}/communities/${values["community"]["slug"]}`}
38+
{`${formConfig.SITE_UI_URL}/communities/${values["metadata"]["slug"]}`}
3939
</>
4040
);
4141

@@ -139,11 +139,18 @@ class CommunityCreateForm extends Component {
139139
const { errors, message } = communityErrorSerializer(error);
140140

141141
if (message) {
142-
this.setGlobalError(message);
142+
this.setGlobalError("The form contains errors or missing fields. Please verify before submitting");
143143
}
144144

145145
if (errors) {
146-
errors.map(({ field, messages }) => setFieldError(field, messages[0]));
146+
errors.map(({ field, messages }) => {
147+
// Check if the field is already prefixed with "metadata"
148+
if (!field.startsWith("metadata")) {
149+
// Add "metadata" prefix if not already present
150+
field = `metadata.${field.split('.').pop()}`;
151+
}
152+
setFieldError(field, messages[0]);
153+
});
147154
}
148155
}
149156
};

0 commit comments

Comments
 (0)