mirror of https://github.com/snachodog/mybuddy.git
Add an initial New Baby form (WIP).
This commit is contained in:
parent
6f0b8500fb
commit
2247d5f9e6
|
@ -4,7 +4,11 @@ from __future__ import unicode_literals
|
|||
from django.conf.urls import url, include
|
||||
from django.contrib import admin
|
||||
|
||||
from core import views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^baby/new/$', views.BabyFormView.as_view(), name='baby_new'),
|
||||
|
||||
url(r'^admin/', admin.site.urls),
|
||||
url(r'', include('api.urls')),
|
||||
]
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.forms import fields, widgets
|
||||
from djng.styling.bootstrap3.forms import Bootstrap3Form
|
||||
|
||||
|
||||
class BabyForm(Bootstrap3Form):
|
||||
use_required_attribute = False
|
||||
|
||||
first_name = fields.CharField(
|
||||
label='First name',
|
||||
min_length=3,
|
||||
max_length=20)
|
||||
|
||||
last_name = fields.RegexField(
|
||||
r'^[A-Z][a-z -]?',
|
||||
label='Last name',
|
||||
error_messages={'invalid': 'Last names shall start in upper case'})
|
||||
|
||||
birth_date = fields.DateField(
|
||||
label='Date of birth',
|
||||
widget=widgets.DateInput(attrs={'validate-date': '^(\d{4})-(\d{1,2})-(\d{1,2})$'}),
|
||||
help_text='Allowed date format: yyyy-mm-dd')
|
|
@ -0,0 +1,9 @@
|
|||
<script type="text/javascript">
|
||||
angular.module('djangular-demo', ['djng.forms']);
|
||||
</script>
|
||||
|
||||
<form method="post" action="babyblotter" validate>
|
||||
{% csrf_token %}
|
||||
{{ form.as_div }}
|
||||
<button type="submit" class="btn btn-primary">Subscribe</button>
|
||||
</form>
|
|
@ -0,0 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.views.generic.edit import FormView
|
||||
|
||||
from core.forms import BabyForm
|
||||
|
||||
|
||||
class BabyFormView(FormView):
|
||||
template_name = 'baby-form.html'
|
||||
form_class = BabyForm
|
||||
success_url = reverse_lazy('form_data_valid')
|
Loading…
Reference in New Issue