2015-09-18 18 views
0

我有我認爲是一個簡單的SimpleSchema與我目前有兩個模板。其中一個包含一個將新文檔插入集合的快速表單,另一個快速表單應該從第一個模板更新文檔。流星Autoform/SimpleSchema - quickform(type =「update」)不起作用

插入表單工作正常,但是當我嘗試加載更新模板時,我的控制檯顯示以下錯誤並且提交按鈕不起作用。根據有類似問題的人,錯誤通常是由遞歸函數引起的,但我無法在任何地方找到。

Exception from Tracker recompute function: 
debug.js:41 RangeError: Maximum call stack size exceeded 
    at Object (native) 
    at isObject (http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1000:18) 
    at isBasicObject (http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1024:10) 
    at parseObj (http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1147:15) 
    at http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1159:11 
    at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:159:22) 
    at parseObj (http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1155:9) 
    at http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1159:11 
    at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:159:22) 
    at parseObj (http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1155:9) 

這裏是我的兩個模板:

<template name="newWeddingPage1"> 
    <div class=" col-sm-10 col-sm-offset-1"> 
    <div class=" col-md-6"> 
     <div class="well well-sm"> 

     {{> quickForm collection="Weddings" id="insertWeddingInfo1" omitFields="email, phone, name, price" type="insert"}} 

    </div> 
    </div> 

    <div class=" col-md-6"> 
     <div class="well well-sm"> 
     {{#each theweddingdetails}} 
     <h1 id="price">{{duration}}</h1> 
     {{/each}} 


    </div> 
    </div> 



    </div> 
</template> 


<template name="newWeddingPage2"> 
    <div class=" col-sm-10 col-sm-offset-1"> 
    <div class=" col-md-6"> 
     <div class="well well-sm"> 
     {{#each theweddingdetails}} 
     {{> quickForm collection="Weddings" id="updateWeddingInfo1" doc="this" omitFields="email, phone, name, price" type="update"}} 
     {{/each}} 

    </div> 
    </div> 


    </div> 
</template> 

和我簡單的模式在這裏:

Weddings.attachSchema(new SimpleSchema({ 

    address: { 
    type: String, 
    label: "Address", 
    optional: true 
    }, 
    startDate: { 
    type: Date, 
    label: "Date of shooting", 
    optional: false, 
    }, 
    startTime: { 
    type: String, 
    optional: true, 
    autoform: { 
     afFieldInput: { 
     type: "time" 
     } 
    } 
    }, 
    duration: { 
    type: Number, 
    label: "Duration (in hours)", 
    optional: true 
    }, 
    price: { 
    type: Number, 
    label: "Price", 
    optional: true, 
    autoform: { 
     type: "hidden", 
     label: false 
    }, 
    autoValue:function(){ return 0 } 
    }, 
    email: { 
    type: String, 
    optional: true, 
    autoform: { 
     afFieldInput: { 
     type: "email" 
     } 
    } 
    }, 
    phone: { 
    type: Number, 
    optional: true, 
    autoform: { 
     afFieldInput: { 
     type: "tel" 
     } 
    } 
    }, 
    name: { 
    type: String, 
    label: "Contact Person", 
    optional: true 
    }, 
    createdBy: { 
    type: String, 
    autoform: { 
     type: "hidden", 
     label: false 
    }, 
    autoValue:function(){ return this.userId } 
}, 
createdAt: { 
    type: Date, 
    autoform: { 
     type: "hidden", 
     label: false 
    }, 
    autoValue:function(){ return new Date(); } 
} 
})); 

任何人有一個線索,我要去哪裏錯了嗎?

已與位玩弄對於現在的最後幾個小時:/

回答

1

在你更新表單,你有doc="this",這意味着你只是傳遞一個字符串「這種」爲您的文檔。

嘗試doc=this,不含引號。這樣,您將傳遞上下文變量this作爲您的文檔。我假設在您的路由器或其他地方,您已經通過相應的文檔作爲您的數據上下文,以便它可在this

+1

謝謝!你是一個美麗的人。 – Louisswiss