You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're using Meteor 1.3.2.4 and are using the imports directory. I tried to get things working with the example code, but they didn't. The validation seemed to work et al, but "this" returned as an empty object. No error in the log or anything like that.
The examples use the variable named "context" and looking through the history.md I noticed that it should be formContext. When I made that alteration I was given the following errors:
TypeError: component.submitted.get is not a function
and
TypeError: Cannot read property 'validateOne' of undefined
FormContext exist as described.
I made a fresh project with
meteor create
and added this package
meteor add templating:forms
I got the same errors as above. One for every element I've included.
My formBlock template:
<template name="formBlock">
<form>
{{> UI.contentBlock data=data context=formContext }}
{{#if invalid}}
<strong>Can't submit!</strong>
There are <span class="badge">{{invalidCount}}</span> invalid fields!
{{/if}}
{{#if failed}}
<strong>Woops!</strong>
There was a problem submitting the form!
{{/if}}
</form>
</template>
My formElement template:
<template name="inputText">
<input id="{{ field }}" name="{{ field }}" type="text" placeholder={{ instructions }} value={{ value }} class="validate reactive-element">
{{# if label }}<label for="{{ field }}">{{ label }}</label>{{/ if }}
{{#if submitted}}
{{#if errorMessage}}<p class="error-message">{{errorMessage}}</p>{{/if}}
{{/if}}
</template>
main.js
import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import { ReactiveForms } from 'meteor/templates:forms';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
import './main.html';
import './form-block.html';
import './input-field.html';
const schema = new SimpleSchema({
test: {
type: String
}
});
Template.hello.onCreated(function helloOnCreated() {
// counter starts at 0
this.counter = new ReactiveVar(0);
});
Template.hello.helpers({
counter() {
return Template.instance().counter.get();
},
schema() {
return schema;
},
action() {
return (elements, callbacks, changed) => {
console.log("[forms] Action running!");
console.log("[forms] Form data!", this);
console.log("[forms] HTML elements with `.reactive-element` class!", elements);
console.log("[forms] Callbacks!", callbacks);
console.log("[forms] Changed fields!", changed);
};
}
});
Template.hello.events({
'click button'(event, instance) {
// increment the counter when button is clicked
instance.counter.set(instance.counter.get() + 1);
},
});
ReactiveForms.createFormBlock({
template: 'formBlock',
submitType: 'normal'
});
ReactiveForms.createElement({
template: 'inputText',
validationEvent: 'keyup',
reset: function (el) {
$(el).val('');
}
});
We're using Meteor 1.3.2.4 and are using the imports directory. I tried to get things working with the example code, but they didn't. The validation seemed to work et al, but "this" returned as an empty object. No error in the log or anything like that.
The examples use the variable named "context" and looking through the history.md I noticed that it should be formContext. When I made that alteration I was given the following errors:
and
FormContext exist as described.
I made a fresh project with
and added this package
I got the same errors as above. One for every element I've included.
My formBlock template:
My formElement template:
main.js
main.html
versions
The text was updated successfully, but these errors were encountered: