yogiben / meteor-admin

A complete admin dashboard solution
https://atmospherejs.com/yogiben/admin
GNU General Public License v3.0
826 stars 261 forks source link

How to update collection with custom edit template? #296

Closed amandasaffer closed 8 years ago

amandasaffer commented 8 years ago

Hi, I'm working with a Content collection that I'm trying to define some custom templates for. I can create new collection items just fine, but when I try to edit an existing one using my custom template, I'm getting an error Exception while invoking method 'adminUpdateDoc' TypeError: Cannot call method 'update' of undefined. When I test Session.get('admin_collection_name') in the console it's printing out "Content" as it should.

I have these templates defined in admin_config.js:

new: {
  name: 'AdminDashboardContentNew'
},
edit: {
  name: 'AdminDashboardContentEdit'
}

The AdminDashboardContentNew template works fine, since it's pretty simple right now for testing:

<template name="AdminDashboardContentNew">
    <div class="box box-default">
        <div class="box-body">
        {{> adminAlert}}
        {{# autoForm id="admin_insert" schema=AdminSchemas.Content type="method" meteormethod="adminInsertDoc"}}

            {{>afQuickField name="page" options="allowed"}}         
            {{>afQuickField name="headline"}}
            {{>afQuickField name="content"}}
            <button type="submit" class="btn btn-primary">Add Content</button>
        {{/autoForm}}
        </div>
    </div>
</template>

And here is my AdminDashboardContentEdit template for reference:

<template name="AdminDashboardContentEdit">
    {{> adminAlert}}
    <div class="box box-default">
        <div id="content-edit" class="box-body">
            {{#if admin_current_doc}}
                {{# autoForm id="admin_update" doc=admin_current_doc schema=AdminSchemas.Content type="method" meteormethod="adminUpdateDoc"}}
                    {{>afQuickField name="page" options="allowed"}}
                    {{>afQuickField name="headline"}}
                    {{>afQuickField name="content"}}
                    <button type="submit" class="btn btn-primary">Update Page</button>
                {{/autoForm}}
            {{/if}}
        </div>
    </div>
</template>

Any help would be greatly appreciated, don't know where I'm going wrong here!

amandasaffer commented 8 years ago

I solved this by not trying to use the provided autoform hooks and instead building my own!