2017-05-23 13 views
1
내가 추가 한
  1. 자동 폼의 패키지로 구성 표시되지 않는 자동 폼 유효성 검사 메시지 (유성 aldeed 추가 : 자동 폼)
  2. 을 나는 collection2 코어 패키지로 구성 간결체 한자 스키마
  3. 내가 설치 한 (유성 collection2 코어를 추가) 추가했습니다 (NPM 내가 --save 간결체 한자 스키마) 하지만 형태는 여전히 제대로 작동하지 않는

/imports/api/rooms/rooms.js유성 1.4.

import { Tracker } from 'meteor/tracker'; 
import { Mongo } from 'meteor/mongo'; 
import SimpleSchema from 'simpl-schema'; 
SimpleSchema.extendOptions(['autoform']); 

export const Rooms = new Mongo.Collection('rooms'); 

Rooms.attachSchema(new SimpleSchema({ 
    title: { 
     type: String, 
     label: 'Title' 
    }, 
    desc: { 
     type: String, 
     label: 'Description' 
    }, 
    createdAt: { 
     type: Date, 
     autoValue(){ 
      return new Date(); 
     } 
    }, 
}), {tracker: Tracker}); 

/꼬마 도깨비 ORTS/UI/페이지/home.js

import { Template } from 'meteor/templating'; 

import './home.html'; 

import { Rooms } from '../../api/rooms/rooms.js' 

Template.Home.helpers({ 
    rooms() { 
     return Rooms.find({}); 
    }, 
    CollectionRooms() { 
     return Rooms; 
    } 
}); 

/imports/ui/pages/home.html

<template name="Home"> 
    <div class="jumbotron"> 
     <div class="container text-center"> 
      <h1>Forum</h1> 
      <p>“Don't raise your voice, improve your argument."</p> 
     </div> 
    </div> 

    <div class="container-fluid bg-3"> 
     <h3 class="page-header">Choose your room</h3> 

     {{> quickForm collection=CollectionRooms id="insertRoomsForm" type="insert"}} 

     <div class="row grid-divider"> 
     {{#each rooms}} 
      <div class="col-sm-4"> 
       <div class="col-padding"> 
        <h3>{{title}}</h3> 
        <p>{{desc}}</p> 
       </div> 
      </div> 
     {{/each}} 
     </div> 
    </div> 
</template> 

패키지

[email protected]    # Packages every Meteor app needs to have 
[email protected]  # Packages for a great mobile UX 
[email protected]     # The database Meteor supports right now 
[email protected] # Compile .html files into Meteor Blaze views 
[email protected]   # Reactive variable for tracker 
[email protected]     # Meteor's client-side reactive programming library 

[email protected] # CSS minifier run for production mode 
[email protected] # JS minifier run for production mode 
[email protected]    # ECMAScript 5 compatibility for older browsers. 
[email protected]    # Enable ECMAScript2015+ syntax in app code 
[email protected]   # Server-side component of the `meteor shell` command 

[email protected]    # Publish all data to the clients (for prototyping) 
[email protected]    # Allow all DB writes from clients (for prototyping) 
twbs:bootstrap 
iron:router 
aldeed:autoform 
aldeed:collection2-core 

내가 양식을 참조하고에 기록을 삽입 데이터베이스,하지만 유효성 검사 메시지가 표시되지 않는 이유는 "만든"필드가 있습니까? 내가 뭘 잘못하고있어? enter image description here

+1

당신은'AutoForm.debug을()'일을하고 폼을 다시 제출하고 당신이 그것을 보여 기대하고 무엇 검증 메시지 오류 –

+1

가 있는지 사용해 볼 수 있습니까? 빈 양식을 제출하면 DB에 무엇이 저장됩니까? 둘째,''createdAt'''는 스키마에 명시되어 있기 때문에 보여지고 있습니다. 숨겨진 필드가 필요한 경우 다음을 사용하십시오.'''createdAt : { 유형 : 날짜, autoValue() { return new Date(); }, 자동 폼 : { 유형 :''} } "숨겨진"'도움이 autoValue으로 파악하기 위해 – blueren

+0

@blueren 덕분에, 나는 네 바로 프로그래밍 차종, 그것은 기본적 –

답변

3

스키마에 오타가있어 트래커가 포함되지 않습니다. 이로 인해 양식에 유효성 검사 메시지가 나타나지 않습니다. 수정 된 코드는 다음과 같습니다

Rooms.attachSchema(new SimpleSchema({ 
    title: { 
     type: String, 
     label: 'Title' 
    }, 
    desc: { 
     type: String, 
     label: 'Description' 
    }, 
    createdAt: { 
     type: Date, 
     autoValue(){ 
      return new Date(); 
     } 
    }, 
}, {tracker: Tracker})); 
+0

감사에 의해 숨겨진 필드하게 생각 사람 장님). 나는 시간 낭비했다. 너는 내 생명을 구했어.) –