mirror of https://github.com/snachodog/mybuddy.git
Use form classes to set appropriate field attributes in date/time fields.
Using a custom input element in the template caused issues with default values (e.g. when set by a timer).
This commit is contained in:
parent
dad1ff73ca
commit
98963572ba
|
@ -28,12 +28,11 @@
|
|||
<div class="input-group-addon" data-target="#datetimepicker_{{ field.name }}" data-toggle="datetimepicker">
|
||||
<i class="fa fa-calendar"></i>
|
||||
</div>
|
||||
<input name="{{ field.html_name }}"
|
||||
required="{{ field.required }}"
|
||||
class="form-control datetimepicker-input{% if field.errors %} is-invalid{% endif %}"
|
||||
data-target="#datetimepicker_{{ field.name }}"
|
||||
id="id_{{ field.name }}"
|
||||
type="text"/>
|
||||
{% if field.errors %}
|
||||
{{ field|add_class:"form-control is-invalid" }}
|
||||
{% else %}
|
||||
{{ field|add_class:"form-control" }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -44,8 +44,7 @@ class ChildForm(forms.ModelForm):
|
|||
widgets = {
|
||||
'birth_date': forms.DateInput(attrs={
|
||||
'class': 'datepicker-input',
|
||||
'data-toggle': 'datetimepicker',
|
||||
'data-target': '#id_birth_date',
|
||||
'data-target': '#datetimepicker_date',
|
||||
}),
|
||||
}
|
||||
|
||||
|
@ -57,8 +56,7 @@ class DiaperChangeForm(forms.ModelForm):
|
|||
widgets = {
|
||||
'time': forms.DateTimeInput(attrs={
|
||||
'class': 'datepicker-input',
|
||||
'data-toggle': 'datetimepicker',
|
||||
'data-target': '#id_time',
|
||||
'data-target': '#datetimepicker_time',
|
||||
}),
|
||||
}
|
||||
|
||||
|
@ -74,13 +72,11 @@ class FeedingForm(forms.ModelForm):
|
|||
widgets = {
|
||||
'start': forms.DateTimeInput(attrs={
|
||||
'class': 'datepicker-input',
|
||||
'data-toggle': 'datetimepicker',
|
||||
'data-target': '#id_start',
|
||||
'data-target': '#datetimepicker_start',
|
||||
}),
|
||||
'end': forms.DateTimeInput(attrs={
|
||||
'class': 'datepicker-input',
|
||||
'data-toggle': 'datetimepicker',
|
||||
'data-target': '#id_end',
|
||||
'data-target': '#datetimepicker_end',
|
||||
}),
|
||||
}
|
||||
|
||||
|
@ -106,13 +102,11 @@ class SleepForm(forms.ModelForm):
|
|||
widgets = {
|
||||
'start': forms.DateTimeInput(attrs={
|
||||
'class': 'datepicker-input',
|
||||
'data-toggle': 'datetimepicker',
|
||||
'data-target': '#id_start',
|
||||
'data-target': '#datetimepicker_start',
|
||||
}),
|
||||
'end': forms.DateTimeInput(attrs={
|
||||
'class': 'datepicker-input',
|
||||
'data-toggle': 'datetimepicker',
|
||||
'data-target': '#id_end',
|
||||
'data-target': '#datetimepicker_end',
|
||||
}),
|
||||
}
|
||||
|
||||
|
@ -154,13 +148,11 @@ class TummyTimeForm(forms.ModelForm):
|
|||
widgets = {
|
||||
'start': forms.DateTimeInput(attrs={
|
||||
'class': 'datepicker-input',
|
||||
'data-toggle': 'datetimepicker',
|
||||
'data-target': '#id_start',
|
||||
'data-target': '#datetimepicker_start',
|
||||
}),
|
||||
'end': forms.DateTimeInput(attrs={
|
||||
'class': 'datepicker-input',
|
||||
'data-toggle': 'datetimepicker',
|
||||
'data-target': '#id_end',
|
||||
'data-target': '#datetimepicker_end',
|
||||
}),
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue