Default Value not rendering rest of the form (autoform)


#1

Hi,

I am building a form using auto-form where in I need to show/hide the rest of the form based on a radio button selected. The rerequisite is that Option A of the readio button is by default selected while the page is opened. But the rest of the form pertaining to option A is not getting rendered.
It only works after I select Option B and then Option A again. How do I go about this?

Schema:

 "type":{
        type: String,
        //defaultValue: 'well-known',
        autoform:{
            type: "select",
            options: function(){
                return [
                    {label: "Option A", value: "option-a"},
                    {label: "Option B", value: "option-b"}
                ];
            }
        }
    },
{...Option A schema...},
{...Option B schema...}

Template:

{{> afQuickField name ="type"}}
    
    {{#if afFieldValueIs name="type" value="option-a"}}
        {{> afQuickField name="option__A"}} 
    {{/if}}
    
    {{#if afFieldValueIs name="type" value="option-b"}}
        {{> afQuickField name="option__B" }} 
    {{/if}}

NOTE: This is in partial continuation of this post. @hwillson


#2

There were a few issues about this reported a little while back:

Which version of Autoform are you using? Maybe double check that you have the latest version.

If that doesn’t help, then it sounds like the issue still persists. Maybe open/update an issue via Autoform’s repo, or if you need a solution quickly look into writing your own custom hide/show helper like @abernix outlined here.


#3

spot on! Looks like the manual helper to handle this works fine! These are everthing pertaining to aldeed I have installed

aldeed:autoform@5.8.1
aldeed:collection2@2.9.1
aldeed:collection2-core@1.1.1
aldeed:schema-deny@1.0.1
aldeed:schema-index@1.0.1
aldeed:simple-schema@1.5.3

Thanks as always @hwillson !