Skip to content

Conversation

@EinLama
Copy link
Contributor

@EinLama EinLama commented Jan 2, 2026

Ticket

https://community.openproject.org/wp/70106

What are you trying to accomplish?

Fields that are required and have a default value will no longer be activated for new projects and will thus not show up in the new project wizard.

This is done by teaching the NewProjectService to treat custom fields with the default value set to be treated like a custom field with no value set.

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

@EinLama EinLama force-pushed the bug/70106-required-project-attribute-with-default-value-not-for-all-showing-up-in-list-of-required-attributes-on-project-creation branch 4 times, most recently from 1b1ba92 to badea74 Compare January 2, 2026 12:43
@EinLama EinLama marked this pull request as ready for review January 2, 2026 12:48
@EinLama EinLama marked this pull request as draft January 2, 2026 12:54
@EinLama EinLama force-pushed the bug/70106-required-project-attribute-with-default-value-not-for-all-showing-up-in-list-of-required-attributes-on-project-creation branch 2 times, most recently from 6c8d53f to fa450e8 Compare January 5, 2026 13:39
@EinLama EinLama marked this pull request as ready for review January 5, 2026 13:39
@ulferts ulferts self-requested a review January 6, 2026 08:56
Copy link
Contributor

@ulferts ulferts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @EinLama , I found a bug when using the API. Sorry, custom fields are nasty.

!cv.is_for_all? &&
# Mind that a present value could just be the default value. Treat it as blank in that case:
(cv.value.blank? || cv.default?)
end.pluck(:custom_field_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach has the drawback of not activating a custom field if a client creates the project via the api sending the default value along.

Image

In this example, the custom option 10 is the default value of custom field 518. Since it is the default value, the field will be deactivated subsequently.

This can be mitigated by checking in the params if the custom field was provided. It might even be possible to rely on params in the build_missing_project_custom_field_project_mappings step and by that completely get rid of the need to clean up here afterwards.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dang, good point. I dismissed most of the API since we have another bug ticket for it. But this bug is NOT part of that ticket, so thanks for pointing it out.

As for the params idea: I tried it and this approach works. As you predicted, we do not even have to delete unwanted values anymore.

@EinLama EinLama force-pushed the bug/70106-required-project-attribute-with-default-value-not-for-all-showing-up-in-list-of-required-attributes-on-project-creation branch from 2d90938 to 5d90f6a Compare January 7, 2026 09:56
Without this commit, unwanted fields would still show up in the creation
form, as the NewProjectService will always create the mappings. But it
will only remove unwanted mappings after successfully persisting the
project. This does not happen if there are errors (e.g. a required field
has no value). Since the field should never have been activated in the
first place, it is expected to have no value. Still, this validation
errors prohibits saving - and thus the errornous field is never cleaned
up.
... even if it is identical to the default value
@EinLama EinLama force-pushed the bug/70106-required-project-attribute-with-default-value-not-for-all-showing-up-in-list-of-required-attributes-on-project-creation branch from 5d90f6a to 350771d Compare January 7, 2026 09:56
Copy link
Contributor

@ulferts ulferts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works like a charm, @EinLama .

Thanks for the test coverage.

@EinLama EinLama merged commit d8bbc35 into release/17.0 Jan 7, 2026
17 checks passed
@EinLama EinLama deleted the bug/70106-required-project-attribute-with-default-value-not-for-all-showing-up-in-list-of-required-attributes-on-project-creation branch January 7, 2026 14:01
@github-actions github-actions bot locked and limited conversation to collaborators Jan 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants