Did I find the right examples for you? yes no

All Samples(8)  |  Call(4)  |  Derive(0)  |  Import(4)
A function that returns data from the form in a nice way ready for
tabbed view.

        def tabify_form(form):
    """
        A function that returns data from the form in a nice way ready for
        tabbed view.
    """
    children = []
    mappings = []
    for i in form.children:
        if type(i.typ) is Mapping:
            mappings.append({'title': i.title,
                             'name': i.name,
                             'children': i,
                             })
        else:
            children.append(i)

    return {
        'basic': children,
        'other': mappings,
        'only_one': mappings == [],
        'have_basic': len(children) > 1 or len(children) == 1 and children[0].name != 'csrf_token'
    }
        


src/d/e/deform_bootstrap-0.2.9/deform_bootstrap/tests/test_form.py   deform_bootstrap(Download)
    def test_tabify_form_empty(self):
        from deform_bootstrap.utils import tabify_form
 
        form = DummyForm()
 
        result = tabify_form(form)
    def test_tabify_form_no_mappings(self):
        from deform_bootstrap.utils import tabify_form
        children = [
            DummyField("Title", "title"),
            DummyField("Description", "description")
        ]
        form = DummyForm(children)
 
        result = tabify_form(form)
    def test_tabify_form_mappings(self):
        from deform_bootstrap.utils import tabify_form
        children = [
            DummyField("Title", "title"),
            DummyField("Description", "description")