Help with AutoForm field values


#1

Hello,

I’m trying to get my schema to work with autoform. The scenario is that I want the remainder of the form to show up only upon clinking the Yes/No radio button. I tried following what was mentioned in the autoform help pages using both afFieldValueIs and afFieldValueContains however, upon clicking the Yes radio, nothing happens. Where am I going wrong?

Here’s my snippet

dummyCollectionSchema = new SimpleSchema({
     "Name": {
        type: String,
        optional: false,
        unique: true
    },
    "Enable": {
        type: Boolean,
        label: "Do you want to enable this option?",
        autoform:{
            type: "boolean-radios",
            trueLabel: "Yes",
            falseLabel: "No",
            value: false
        }
    },
   "option2": {type: option2_schema}    
});

Template:

<template name ='testAutoForm'>
    <div>
    {{#autoForm collection="dummyCollection" type="insert" id="dummyCollection"}}
        {{> afQuickField name ="Name"}}
  {{> afQuickField name="Enable" options="allowed" noselect=false}}
  {{#if afFieldValueIs name = "Enable" value = "true"}}
    {{> afQuickField name="option2"}}
  {{/if}}
{{/autoForm}}
    </div>
    </template>

#2

In this line "true" is interpreted as a String. Since you want to check against a Boolean, try using true without the quotes, so:

{{#if afFieldValueIs name="Enable" value=true}}

#3

Awesome. Working now. Such a silly error on my part. Thanks!!