2
votes

By meteor autoform,

I can get the label by

{{> afFieldLabel name="myLabelName"}}

I can also automatically generate a input field by

{{> afFieldInput name="myLabelName"}}

What if I only want to show the value of the field? I expect there should be something like

{{> afFieldValue name="myLabelName" }}
2

2 Answers

9
votes

This is late. I'm sure you already figured this out, but here you go anyway. This will get you the field name (reactively):

var someValue = AutoForm.getFieldValue("fieldName" , "formId");

Then you can place this value anywhere you like within your template.

0
votes

Actually you should use:

var someValue = AutoForm.getFieldValue("fieldName");

in your template helpers. If you omit formId, form value will not behave correctly after a page reload. See https://github.com/aldeed/meteor-autoform/blob/devel/CHANGELOG.md#500 for reference:

Compatibility break: The function signature for AutoForm.getFieldValue is reversed from (formId, fieldName) to (fieldName, [formId]) with formId optional. You must not pass the formId argument when using it in a helper that is run within the context of the form. Conversely, you must pass formId if not calling it within an autoform.