Hi,
I am having some issues with making my form/model fields not required. Currently this is the code that I have:
forms.py:
class startRound(forms.ModelForm):
player_2 = forms.CharField(widget=forms.TextInput(attrs={'disabled':'True', 'hidden':'True', 'id':'player_2'}))
player_3 = forms.CharField(widget=forms.TextInput(attrs={'disabled':'True', 'hidden':'True', 'id':'player_3'}))
player_4 = forms.CharField(widget=forms.TextInput(attrs={'disabled':'True', 'hidden':'True', 'id':'player_4'}))
class Meta:
model = parentRounds
models.py
class parentRounds(models.Model):
Name = models.CharField(max_length=200)
player_1 = models.CharField(max_length=25)
player_2 = models.CharField(max_length=25, null=True, blank=True)
player_3 = models.CharField(max_length=25, null=True, blank=True)
player_4 = models.CharField(max_length=25, null=True, blank=True)
started_on = models.DateTimeField(auto_now_add=True)
completed = models.BooleanField(default = False)
The template is just the generic {{ form.player_1 }} with some jquery to hide/show player 2,3,4 depending on the select box value for number of players. Before I started adding jquery code to the template, this worked fine.
Any ideas what could have happened?!
Thanks in advance!
Brendan