def METHOD_NAME(self, request, form, problem_instance):
    super(TeamsMixinForContestController, self).METHOD_NAME(
        request, form, problem_instance
    )
    try:
        tm = TeamMembership.objects.get(
            user_id=request.user.id, team__contest=request.contest
        )
        if not is_contest_admin(request):
            form.fields['user'] = UserSelectionField(
                initial=tm.team.user,
                label=_("Team name"),
                widget=forms.TextInput(attrs={'readonly': 'readonly'}),
                help_text=_(
                    "You are in the team, so submission will"
                    " be sent as the team."
                ),
            )
            def clean_user():
                user = form.cleaned_data['user']
                try:
                    tm = TeamMembership.objects.get(
                        user=request.user, team__contest=request.contest
                    )
                    if user != tm.team.user:
                        raise forms.ValidationError(
                            _("You can't submit a solution for another team!")
                        )
                    return user
                except TeamMembership.DoesNotExist:
                    raise forms.ValidationError(_("Team does not exist"))
            form.clean_user = clean_user
        else:
            form.fields['team'] = forms.CharField(
                initial=tm.team.name,
                label=_("Team name"),
                widget=forms.TextInput(attrs={'readonly': 'readonly'}),
                help_text=_(
                    "You are in the team, but you are also the "
                    "admin, so you can send solution as the "
                    "team user or as yourself."
                ),
            )
    except TeamMembership.DoesNotExist:
        pass