               #   defaultValue         : no
 
     modal = new KDModalViewWithForms modalOptions
+    modal.modalTabs.forms["General Settings"].on "FormValidationFailed", ->
+      modal.modalTabs.forms["General Settings"].buttons.Save.hideLoader()
 
   handleError =(err, buttons)->
     unless buttons


  showGroupSubmissionView:->

    verifySlug = (userSlug)->
      slugField = modal.modalTabs.forms["General Settings"].inputs.Slug
      KD.remote.api.JName.one
        name : "#{userSlug}"
      , (err,name)=>
        if name
          slugField.setClass 'slug-taken'
          suggestSlug userSlug
        else
          slugField.unsetClass 'slug-taken'
          delete slugField.tooltip

    makeSlug = (title)=>
      if title.length == 0
        return
      queryDB @utils.slugify(title), (newSlug)->
        modal.modalTabs.forms["General Settings"].inputs.Slug.setValue newSlug

    queryDB = (userSlug, callback)->
      KD.remote.api.JName.one
        name : "#{userSlug}"
      , (err,name)=>
        unless name
          callback userSlug
        else
          existingSlug = name.name
          if '-' in existingSlug
            parts = existingSlug.split('-')
            suffix = parseInt parts[parts.length - 1]
            if not isNaN(suffix)
              parts[parts.length - 1] = suffix + 1
              existingSlug = parts.join('-')
            else
              existingSlug += '-1'
          else
            existingSlug += '-1'
          queryDB existingSlug, callback

    suggestSlug = (userSlug)->
      slugField = modal.modalTabs.forms["General Settings"].inputs.Slug
      if userSlug.length > 0
        queryDB userSlug, (newSlug)->
          slugField.setTooltip
            title     : "<b>Suggestion:</b> #{newSlug}"
            placement : 'right'
      else
        delete slugField.tooltip

    getGroupType = ->
      modal.modalTabs.forms["Select group type"].inputs.type.getValue()

              "Title"                :
                label                : "Title"
                name                 : "title"
                validate             :
                  event              : "blur"
                  rules              :
                    required         : yes
                keydown              : (pubInst, event)->
                  @utils.defer =>
                    makeSlug()

                placeholder          : 'Please enter your group title...'
              "Slug"                 :
                label                : "Slug"
                name                 : "slug"
                validate             :
                  event              : "blur"
                  rules              :
                    required         : yes
                blur                 : ->
                  @utils.defer =>
                    verifySlug()

                defaultValue         : ""
                placeholder          : 'This value will be automatically generated'
