UEWBot / dipvis

Django-based visualiser for tournaments for the boardgame Diplomacy
GNU General Public License v3.0
7 stars 4 forks source link

Player details page refresh background issue #275

Closed UEWBot closed 9 months ago

UEWBot commented 9 months ago

After adding the "Compare with another player" section, the form insists that picking a player to compare to is mandatory, even if the user presses the "Update background" button. Ideally, it should be mandatory for the "Submit" button but not for the other. Failing that, it should be optional and we should error for comparing with nobody.

UEWBot commented 9 months ago

The form is rendered with <select name="player" required id="id_player">. That particular part is a PlayerChoicefield, derived from ModelChoiceField. All fields default to required=True.

So all we need to do is add required=False to the player field in PlayerForm. But PlayerForm is also used in tournament_player_views.index(), in PlayerFormset.

Regarded as a standalone form, PlayerForm.player being mandatory does make sense.

UEWBot commented 9 months ago

I think the solution is to have two distinct HTML forms on the page, one for updating the background, and one for player comparison. That way, the "required" should just apply within the second form, not the first.