Source

baptism_records / Baptism-Records / baptism_records / widgets / christian_form.py

Full commit
"""Christian Form"""

from tw.api import WidgetsList
from tw.forms import *
from tw.forms.validators import Int, NotEmpty, DateConverter


class ChristianForm(TableForm):
    ministers = enumerate(('-'))
    churches = enumerate(('-'))
    
    fields = [
        HiddenField('id'),
        TextField('book', validator=Int),
        TextField('page', validator=Int),
        TextField('number', validator=Int),
        
        TextField('first_name', validator=NotEmpty),
        TextField('middle_name'),
        TextField('last_name', validator=NotEmpty),
        CalendarDatePicker('birthday', validator=DateConverter()),
        
        Spacer(),
        TextField('father_name', validator=NotEmpty),
        TextField('mother_maiden_name', validator=NotEmpty),
        
        Spacer(),
        TextField('sponsor_1'),
        TextField('sponsor_2'),
        TextField('birth_hospital'),
        TextField('postal_code_id', name="postal_code"),
        
        Spacer(),
        CalendarDatePicker('baptized_on', validator=DateConverter()),
        SingleSelectField('baptized_by', options=ministers),
        SingleSelectField('baptized_at', options=churches),
        
        # FIXME: Having 2 submit buttons with different values isn't working.  Maybe it'll work in tw2.
        # SubmitButton('submit', value='Save', label_text="Save", name="FOO_DAMMIT", css_class="some class", submit_text="Save!"),
        # SubmitButton('submit_and_add_another', value='Save and add another', label_text="Save and add another"),
        ]
    
        


create_christian_form = ChristianForm("create_christian_form", action='/christians/create', 
                                        submit_text='Add new Christian')
edit_christian_form = ChristianForm("edit_christian_form", action='/christians/save', 
                                        submit_text='Save Christian')

class NoteForm(TableForm):
    fields = [
        HiddenField('christian_id'),
        HiddenField('note_type'),
        TextArea('note')
    ]

add_note_form = NoteForm('add_note_form', action='/christians/create_note', submit_text="Save")