Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Required taxonomy fields doesn't present invalid state consistently with other fields #17437

Closed
xtomas opened this issue Jan 31, 2025 · 3 comments · Fixed by #17443
Closed

Required taxonomy fields doesn't present invalid state consistently with other fields #17437

xtomas opened this issue Jan 31, 2025 · 3 comments · Fixed by #17443

Comments

@xtomas
Copy link
Contributor

xtomas commented Jan 31, 2025

Describe the bug

When taxonomy fields are added into content type and required property is set to true, then backend validation occurs and model state error is added into errors. But the error is not correctly bound to the model property, but on the root of the model. So the UI shows error only in validation summary and not under each taxonomy field.

Orchard Core version

2.1.4 but I believe it is from the begging of the taxonomy module.

To Reproduce

  1. Enable taxonomy feature
  2. Create new content type for taxonomy item
  3. Create new taxonomy using taxonomy item type
  4. Add 2 items into new taxonomy
  5. Create new content type and add 3 taxonomy fields with  required settings each with different display settings: one unique with standard view for radio buttons, second with multiple choice and standard view for checkboxes, third with multiple and tags view
  6. Create new instance of content type with 3 taxonomy fields and send it without settings any taxonomy item
  7. There will be errors in summary but not below the each taxonomy fields. And there is no red border showing that the field is in error state like it is done i other content fields.

Expected behavior

Expected behavior is to show validation error message for each invalid taxonomy field and also there should be red border showing invalid state.

Logs and screenshots

Current state after doing repro steps

Image

Expected behavior

Image

@xtomas
Copy link
Contributor Author

xtomas commented Jan 31, 2025

The problem with model state binding is in the drivers. There is missing Prefix when adding error into model state.

TaxonomyFieldDisplayDriver

Image

TaxonomyFieldTagsDisplayDriver

Image

This will fix the problem with the validation error message.

The problem with missing red border can be fixem for example by adding asp-validation-class-for into field edit views.

TaxonomyField-Tags.Edit.cshtml

Image

TaxonomyField.Edit.cshtml

Image

And then add some scss into _validations.scss under OrchardCore.Themes/TheAdmin/scss/components.

Image

Result of this suggestions is shown in expected behavior screenshots.

@hishamco
Copy link
Member

Could you please open a PR for it?

Copy link
Contributor

github-actions bot commented Feb 6, 2025

We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues).

This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants