 #           required    : yes
 #         messages      :
 #           required    : "topic name is required!"
-#     Zikkko            :             
+#     Zikkko            :
 #       label           : "Zikkko"
 #       type            : "textarea"
 #       name            : "zikko"

#       title           : "Reset"
#       style           : "modal-clean-red"
#       type            : "reset"
#   callback            : (formOutput)-> 
#     log formOutput,"  ::::::"
#   fields              :
#     Title             :               
#       label           : "Title:"
#       type            : "text"
#       name            : "title"

    buttons.forEach (buttonOptions)=>
      @buttonField.addSubView button = @createButton buttonOptions
      @buttons[buttonOptions.title] = button

  createField:(data, field)->
    {itemClass, title} = data
    itemClass     or= KDInputView
    data.cssClass or= ""
    field or= new KDView cssClass : "formline #{data.name} #{data.cssClass}"
    field.addSubView label = data.label = @createLabel(data) if data.label
    field.addSubView input = @createInput itemClass,data
    if data.hint
      field.addSubView hint  = new KDCustomHTMLView
        partial  : data.hint
        tagName  : "cite"
        cssClass : "hint"
    @fields[title] = field
    if data.nextElement
      for key, next of data.nextElement
        next.title or= key
        @createField next, field

    return field

  createLabel:(data)->
    return new KDLabelView
      title    : data.label
      cssClass : @utils.slugify data.label

  createInput:(itemClass,options)->
    @inputs[options.title] = input = new itemClass options
    return input

  createButton:(options)->
    options.itemClass or= KDButtonView
    o = $.extend {}, options
    delete o.itemClass
    button = new options.itemClass o


# new KDFormViewWithFields
