CRM-21427 - Add form validation to make it clear we only allow a single website of each type #12582
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Fix for https://issues.civicrm.org/jira/browse/CRM-21427 where websites tend to "disappear" without warning.
Based on the different existing issues and PRs, this PR mainly attempts to consolidate existing behavior, rather than changing anything too deeply, by showing an error when attempting to enter multiple websites of the same type. This seemed illogical for websites without types, and after some testing it seems we can safely allow multiple websites without types.
Before
The second website of any given type will be removed without warning when saving again.
After
Websites without type can be added at will without being removed. Websites with a specified type are only allowed to be added once for each type.
Technical Details
Not many technical changes, the unique website type is a UI validation. #11428 attempted to allow multiple websites of the same type and was reverted. This is partly because of assumptions about website types in templates. However no such assumption would be made for websites without types, as they've only been allowed since #11683.
As discussed in #11694 (point b), there doesn't appear to be a consensus that multiple websites types should be unique, but the current behavior is still counter-intuitive, as it "fixes" the problem silently in a way. Therefore this PR mainly explicitly prohibits the action that was previously suppressed implicitly.
Comments
Tested on CiviCRM 5.3.1