-
Notifications
You must be signed in to change notification settings - Fork 0
/
forms.py
42 lines (40 loc) · 1.61 KB
/
forms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from django import forms
from feedback_app.models import Feedback
from feedback_app import settings as feedback_app_settings
class FeedbackForm(forms.ModelForm):
class Meta(object):
model = Feedback
fields = feedback_app_settings.get_config()["fm_fields"]
fields_placeholders = feedback_app_settings.get_config()["fm_fields_placeholders"]
fields.append('message')
widgets = {}
for field in fields:
if field == 'name':
widgets['name'] = forms.TextInput(
attrs={
'class': 'uk-input',
'placeholder': fields_placeholders[field],
'type': 'text'
})
if field == 'email':
widgets['email'] = forms.EmailInput(
attrs={
'class': 'uk-input',
'placeholder': fields_placeholders[field],
'type': 'email'
})
if field == 'phone':
widgets['phone'] = forms.TextInput(
attrs={
'class': 'uk-input',
'placeholder': fields_placeholders[field],
'type': 'text'
})
if field == 'message':
widgets['message'] = forms.Textarea(
attrs={
'class': 'uk-textarea',
'placeholder': fields_placeholders[field],
'rows': '5',
'required': True
})