形式:
class StartEndDateEpayOperatorsForm(forms.Form):
...
def __init__(self, *args, **kwargs):
super(StartEndDateEpayOperatorsForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
...
self.helper.layout = Layout(
AppendedText('start_date', '<span class="glyphicon glyphicon-calendar"></span>', active=True, css_class='date'),
...
)
表单 HTML:
...
<div class="input-group">
<input id="id_start_date" type="text" class="date dateinput form-control" value="2013-10-01" name="start_date">
<span class="input-group-addon active">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
...
为了使用日历图标作为bootstrap-datepicker触发器,我需要将新的课程日期添加到<div class="input-group">
.
如何使用django-crispy-forms实现它?
目前AppendedText的属性css_class应用于 INPUT 元素而不是父 DIV。
天呐!