'Formstyle for subform rows'

def rowstyle(self, form, fields, *args, **kwargs):

    def render_col(col_id, label, widget, comment, width=None, end=False):
        if comment:
            col = DIV(DIV(widget, comment), _id=col_id)
        else:
            col = DIV(widget, _id=col_id)
        if width:
            column_class = ('small-%s    columns' % width)
            if end:
                column_class = ('%s    end' % column_class)
            col.add_class(column_class)
        return col
    if args:
        col_id = form
        label = fields
        (widget, comment) = args
        return render_col(col_id, label, widget, comment)
    else:
        parent = DIV(_class='row')
        columns = self.columns
        row_actions = self.row_actions
        for (i, (col_id, label, widget, comment)) in enumerate(fields):
            if (columns and (len(columns) > i)):
                width = columns[i]
            else:
                width = 1
            end = ((not row_actions) and (i == (len(fields) - 1)))
            parent.append(render_col(col_id, label, widget, comment, width=width, end=end))
        return parent
