Commit 8eae16f7 authored by Robert's avatar Robert

Revised form and add data-attribute for #534

parent a3849fbf
Pipeline #1220 failed with stage
in 51 seconds
from crispy_forms import helper, layout
from django import forms
import features
......@@ -11,7 +10,8 @@ from . import models
class Create(forms.ModelForm):
author = forms.EmailField(label='E-Mail-Adresse')
subject = forms.CharField(label='Thema', max_length=255)
text = forms.CharField(label='Nachricht', widget=forms.Textarea)
text = forms.CharField(label='Nachricht', widget=forms.Textarea(
{'rows': 5, 'data-component': 'keysubmit autosize'}))
class Meta:
model = associations.Association
......@@ -21,17 +21,8 @@ class Create(forms.ModelForm):
self.has_author = kwargs.pop('has_author')
self.contribution = kwargs.pop('contribution')
super().__init__(*args, **kwargs)
self.helper = helper.FormHelper()
self.helper.layout = layout.Layout(
'subject',
layout.Field('text', rows=5, **{
'data-component': 'keysubmit autosize'
}),
layout.Submit('create', 'Nachricht senden'))
if self.has_author:
del self.fields['author']
else:
self.helper.layout.insert(0, 'author')
def clean(self):
if 'author' in self.cleaned_data:
......
......@@ -25,5 +25,15 @@
{% endblock %}
{% block content %}
{% crispy form %}
<form method="post">
{% csrf_token %}
{% if form.author %}
{% field form.author %}
{% endif %}
{% field form.subject %}
{% field form.text %}
<button class="btn btn-primary" data-publish-submit>
Nachricht senden
</button>
</form>
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment