Calling datepicker from a FormHelper - Using CrispyForms

10 views
Skip to first unread message

chevalier

unread,
Aug 15, 2019, 8:32:09 AM8/15/19
to Django users
I am trying to call my JQuery datepicker from a FormHelper. I just can't find a way to send attributes to JQuery e.g "theme":"dark" etc. This is important for me because i want to define the format type also.

class DeviceFilterFormHelper(FormHelper):


 form_id
= "Device-search-form"
 form_method
= "GET"
 form_tag
= True
 html5_required
= True
 
 layout
= Layout(
 
Div(
 
Div('name', css_class="col-md-6"),
 
Div('location', css_class="col-md-6"),
 css_class
='row'
 
),
 
Div(
 
Div('phone_number', css_class="col-md-6"),
 
Div(Field('updated_date', css_class="date-time-picker", // this is field in which i want to call my attrs which i can't find a way to call
 attrs
={
 
'required': True,
 
'theme': 'dark',
 
'class': 'date-time-picker',
 
'data-options': '{"format":"Y-m-d H:i", "timepicker":"true"}'

 
})),
 css_class
='row'
 
),
 
FormActions(
 
Submit("submit", ("Search"), css_class="col-md-5"),
 css_class
="col-8 text-right align-self-center",
 
),
 
)




Reply all
Reply to author
Forward
0 new messages