 showError          = require 'app/util/showError'
 Encoder            = require 'htmlencode'
 
-createSection = ({name, title, description, expanded}) ->
-
-  expanded ?= no
+
+createSection = (options = {}) ->
+
+  { name, title, description } = options
 
   section = new KDCustomHTMLView
     tagName  : 'section'
-    cssClass : if expanded then 'AppModal-section' else 'AppModal-section is-collapsed'
-
-  section.addSubView new KDCustomHTMLView
-    tagName  : 'header'
-    cssClass : 'AppModal-sectionHeader'
-    partial  : title
+    cssClass : kd.utils.curry 'AppModal-section', name
 
   section.addSubView desc = new KDCustomHTMLView
     tagName  : 'p'
     cssClass : 'AppModal-sectionDescription'
     partial  : description
 
-  desc.addSubView new KDButtonView
-    cssClass     : "AppModal-sectionToggle solid small #{if expanded then 'gray' else 'green'}"
-    title        : if expanded then 'collapse' else 'expand'
-    callback     : ->
-      if section.hasClass 'is-collapsed'
-        section.unsetClass 'is-collapsed'
-        @unsetClass 'green'
-        @setClass 'gray'
-        @setTitle 'collapse'
-      else
-        section.setClass 'is-collapsed'
-        @setClass 'green'
-        @unsetClass 'gray'
-        @setTitle 'expand'
-
   return section
 
 
 addInput = (form, options) ->
 
-  { name, label, description, itemClass } = options
+  { name, label, description, itemClass, nextElement } = options
 
   itemClass  or= KDInputView
   form.inputs ?= {}


    @addSubView section = createSection
      name        : 'deletion'
      title       : 'DELETE TEAM'
      description : 'If Koding is no use to your team anymore, you can delete your team page here.'

    section.addSubView form = new KDFormView

  field.addSubView form.inputs[name] = input = new itemClass options
  field.addSubView new KDCustomHTMLView tagName : 'p', partial : description  if description

  field.addSubView nextElement  if nextElement and nextElement instanceof KDView

  return input

addButton = (form, options) ->
