Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select-radio and select-radio-inline not working for update #1703

Open
pkumar-uk opened this issue Feb 12, 2021 · 10 comments
Open

select-radio and select-radio-inline not working for update #1703

pkumar-uk opened this issue Feb 12, 2021 · 10 comments
Assignees
Milestone

Comments

@pkumar-uk
Copy link

Problem -
Autoform field defined with input type as 'select-radio' or 'select-radio-inline' works well while inserting but does not populate the value of the field in 'update' mode. If the field type is changed to 'select' in update mode the old value is populated.

answerType: { type: String, label: 'Answer Type' , optional: true,
        autoform: {
            type: "select-radio-inline",
            options: function () {
            return [
                { label: "Yes/No", value: '1' },
                { label: "Select Options(Single)", value: '2' },
                { label: "Open Ended", value: '3' },
                { label: "Select Options(Multiple)", value: '4' }, 
            ]
            },
        },

    },

Meteor version 2.0
AutoForm 7.0.0

@jankapunkt
Copy link
Member

Hi @pkumar-uk sorry for the delay I missed this issue. Could you please to ensure proper reproduction add the two autoForm/quickForm defnitions for your insert and update use cases? Thank you, I will then start investigating.

@pkumar-uk
Copy link
Author

The following one is another example where it does not work. Please let me know if more information is required. Thanks

 --- Schema 
let SchemaToDo = new SimpleSchema({
    schoolId: { type: String, optional: false },
    createdDt: {type: Date, optional: false},
    creationId: {type: String, optional: false},
    creationUId: {type: String, optional: false},
    creationBy: {type: String, optional: false},
    modiDt: {type: Date, optional: true},
    modiId: {type: String, optional: true},
    modiUId: {type: String, optional: true},
    modiBy: {type: String, optional: true},
    priority: {type: String, optional: false},
    status: {type: String, optional: false},
    shortDesc: {type: String, optional: false},
    longDesc: {type:String,label: "Content",optional: true,
        autoform:{
            afFieldInput:{
               type: 'summernote',
               class: 'editor',
               settings:{height: 200,
               minHeight:200,
               maxHeight:null,
               imageCollection:'Images',
            }
    }}},
    attachURLMulti: {type: Array,
        label:'Please select supporting docs', 
        optional: true,
        autoform: {
          type: 'slingshot', // (required)
          multi: true,
          ui: {
            noPreview: true,
            hideDownload: true,
            showDownloadAll: false
          },
          slingshot: {
            directives: [{
              name: 'otherLoad'
  
            }]
          }
        }
    }, 
    "attachURLMulti.$":{type:afSlingshot.fileSchema},
    statusDesc: {type:String,label: "Status",optional: true,
        autoform:{
            afFieldInput:{
               type: 'summernote',
               class: 'editor',
               settings:{height: 200,
               minHeight:200,
               maxHeight:null,
               imageCollection:'Images',
            }
    }}},
    statusURLMulti: {type: Array,
        label:'Please select supporting docs',
        optional: true,
        autoform: {
          type: 'slingshot', // (required)
          multi: true,
          ui: {
            noPreview: true,
            hideDownload: true,
            showDownloadAll: false
          },
          slingshot: {
            directives: [{
              name: 'otherLoad'
  
            }]
          }
        }
    }, 
    "statusURLMulti.$":{type:afSlingshot.fileSchema},
    primaryId: {type: String, optional: false},
    primaryName: {type: String, optional: false},
    teamIds: {type: Array, optional: true},
    "teamIds.$": {type: String, optional: true},
    teamNames: {type: Array, optional: true},
    "teamNames.$":{type: String, optional: true},
    infoIds: {type: Array, optional: true},
    "infoIds.$": {type: String, optional: true},
    infoNames: {type: Array, optional: true},
    "infoNames.$":{type: String, optional: true}, 
    todoBy: {type: Date, optional: false},
});

---- Insert
    {{#autoForm collection="ToDo" schema=schema id="instodoMain" template="bootstrap3-horizontal" type="insert" validation="submit"}}
        {{> afQuickField name='shortDesc' label="Title"}} 
        {{> afQuickField name='longDesc' placeholder='To do Description..'}} 
        {{> afQuickField name='attachURLMulti' label="Any attachement?"}}
        {{> afQuickField name='priority' type="select-radio-inline" label="Priority" options=optPriority}}
        {{> afQuickField name='todoBy' type="datetimepicker" label="To be done by Date/Time"}}
        {{> afQuickField name='primaryId' type="select2"    options=optStaffList label="Primary Responsible"}} 
        {{> afQuickField name='teamIds' type="select2"  multiple=true options=optStaffList label="Team Members"}} 
        {{> afQuickField name='infoIds' type="select2"  multiple=true options=optStaffList label="Inform Members"}}    
        <div class="form-group">
            <button type="submit" class="btns3 btn btn-sm btn-primary">Insert</button>
            <button type="reset" class="btn btn-sm btn-default">Reset</button>
        </div>
    {{/autoForm}}

--- Update
    {{#autoForm collection="ToDo" schema=schema id="updtodoMain" doc=doc template="bootstrap3-horizontal" type="update" validation="submit"}}
        {{> afQuickField name='shortDesc' label="Title"}} 
        {{> afQuickField name='longDesc' placeholder='To do Description..'}} 
        {{> afQuickField name='attachURLMulti' label="Any attachement?"}}
        {{> afQuickField name='priority' type="select-radio-inline" label="Priority" options=optPriority}}
        {{> afQuickField name='todoBy' type="datetimepicker" label="To be done by Date/Time"}}
        {{> afQuickField name='primaryId' type="select2"    options=optStaffList label="Primary Responsible"}} 
        {{> afQuickField name='teamIds' type="select2"  multiple=true options=optStaffList label="Team Members"}} 
        {{> afQuickField name='infoIds' type="select2"  multiple=true options=optStaffList label="Inform Members"}}    
        <div class="form-group">
            <button type="submit" class="btns3 btn btn-sm btn-primary">Insert</button>
            <button type="reset" class="btn btn-sm btn-default">Reset</button>
        </div>
    {{/autoForm}}

-- helper
optPriority: ()=> {
        return [
            {label:'High', value:'High'},
            {label:'Medium', value:'Medium'},
            {label:'Low', value:'Low'},
        ]
    }

@jankapunkt
Copy link
Member

I tried to reproduce with a fresh new repo but for me the update form actually updated the document.

Can you take the time and create a minimal GitHub repo, containing only the insertform and update form to allow me to reproduce this issue? Please also do not include any other fields, than the ones involved in the issue (the select radio fields) to avoid any side-effect.

@pkumar-uk
Copy link
Author

I think the issue is not that. The update does work. It is just that in update mode the radio field does not get populated with old value, when Autoform is opened in update mode. If you are not seeing in your code, I will create a min GitHub repo.

@pkumar-uk
Copy link
Author

Please find mini repo https://github.com/pkumar-uk/testapp.git

Not very neat but will help you see the issue.

Insert some records and try updating. The radio type input is not initialised.

@pkumar-uk
Copy link
Author

Please let me know if more information is needed.

@jankapunkt
Copy link
Member

Hey @pkumar-uk the problem lies within the theme and the bootstrap custom radio-button component and not AutoForm itself. Let me check, if there is a potential solution to this

@jankapunkt
Copy link
Member

Created a fix here: Meteor-Community-Packages/meteor-autoform-themes#5

Please checkout and review, if possible so it can be merged and published soon

@pkumar-uk
Copy link
Author

Apologies for not looking at this issue as I had an workaround. I want to confirm that I have tested the changes and they seem to be working

@jankapunkt
Copy link
Member

It should be fixed in version 1.0.6

@jankapunkt jankapunkt added this to the v7 milestone Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants