### codetube
    Copyright (C) 2011 payload payload@lavabit.com
    Copyright (C) 2011 dodo dodo.the.last@gmail.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>
###

attrs =
    method: @method or 'post'
    action: @action or ''
    id    : @id or 'form'
form attrs, ->
    @tabindex or= 1
    for name, entry of @fields
        if name == '_nojs'
            # XXX borked
            #div class: 'no-js', ->
            #    center ->
            #        strong -> text entry
        else if name[0] != '_'
            { widget, widget: { text: _text, type } } = entry
            type =
                if widget
                    if type in ['text', 'password', 'hidden']
                        'input'
                    else type
                else 'input'
            ++@tabindex
            partial "inc/form_#{type}", { name, entry, @tabindex }
    #@partial(@before_submit, text) if @before_submit
    div class: 'submit', ->
        attrs =
            type: 'submit'
            id: 'submit_button'
            value: @fields?._submit or 'submit'
            tabindex: ++@tabindex
        input attrs

