       title : "Forward My Domain"
       
     @forwardForm = new KDFormViewWithFields
-      callback          : =>
-        {modalTabs,parentData} = @getOptions()
-        parentData["selectedDomain"] = @forwardForm.inputs.domainAddress.getValue()
-        parentData["newDomain"] = no
-        modalTabs.showPaneByIndex 2
-        
+      callback          : @bound "saveDomain"
       buttons           :
         Forward         :
           type          : "submit"

    
    super options, data
    
    KD.remote.api.JVM.fetchVms (err, vms)=>
      selects = []
      for i, vmName of vms
        selects.push {
          title :"#{vmName}.kd.io"
          value:"#{vmName}.kd.io"
          }
           
      @emit "UserVMMenuReady", selects
      

    @on "DomainRegistered", (orderInfo) =>
      @modalTabs.forms["Connect"].buttons.Next.hideLoader()
      
      @modalTabs.forms["Done"].addSubView (
        new DomainRegistrationCompleteView {orderInfo : orderInfo}
        )
        
      @modalTabs.showPaneByIndex "3"
      
      
    @on "DomainForwarded", (orderInfo) =>
      @modalTabs.forms["Connect"].buttons.Next.hideLoader()
      
      @modalTabs.forms["Done"].addSubView (
        new DomainForwardingCompleteView {orderInfo : orderInfo}
        )
        
      @modalTabs.showPaneByIndex "3"
      
      
  loadSearchDomainPane:->
    @modalTabs.showPaneByIndex 1
    @setData {}
    
    
    if actionState is "new"
      
      @modalTabs.forms["Find Your Domain"].addSubView (
        new DomainSearchForm { 
          modalTabs  : @modalTabs
          parentData : @getData()
          }
        )
    else
      
      @modalTabs.forms["Find Your Domain"].addSubView (
        new DomainForwardForm {
          modalTabs  : @modalTabs
          parentData : @getData()
          }
        )
        
  saveDomainInformation:->
    {selectedDomain, newDomain} = @getData()
    
    if newDomain 
      VMToBind = @modalTabs.forms["Connect"].inputs.SelectVM.getValue()
      KD.remote.api.JDomain.registerNewDomain {domainAddress:selectedDomain, selectedVM : VMToBind}, (err, orderInfo)=>
        @emit "DomainRegistered", orderInfo
    else
      VMToBind = @modalTabs.forms["Connect"].inputs.SelectVM.getValue()
      KD.remote.api.JDomain.addNewDNSRecord {domainAddress:selectedDomain, selectedVM : VMToBind}, (err, orderInfo)=>
        @emit "DomainForwarded", orderInfo

    
class DomainSearchForm extends KDScrollView

        domainName      :
          label         : "Domain Name:"
          name          : "domainName"
          placeholder   : "Domain (e.g. example.com)"
          validate      :
            rules       :
              required  : yes
