vazco / meteor-universe-autoform-select

Meteor universe autoform select
MIT License
16 stars 10 forks source link

"optionsMethodParams" support function callback? #22

Closed thearabbit closed 8 years ago

thearabbit commented 8 years ago

I would to change the options value depend on other field changed.

dependField: {
.......
}
.........
fundId: {
        type: [String],
        label: 'Fund',
        autoform: {
            type: 'universe-select',
            afFieldInput: {
                multiple: true,
                optionsMethod: 'loan_listFundOnProduct',
                optionsMethodParams: function(){
                  var dependField = AutoForm.getFieldValue('dependField');
                  return {dependField: dependField};
               }
            }
        }
    }

So I need optionsMethodParams to support function callback? Please help me.

MichalW commented 8 years ago

Please try version 0.2.1, I allowed to use the function in optionsMethodParams

thearabbit commented 8 years ago

Thanks for quickly reply. I love this package, because I have many problem with select dropdown that get data from the server. Excuse me, could you solve issue #19 to use arrow key to select item list.

thearabbit commented 8 years ago

Now it work fine, but it don't reactive to change params to server when I change value of AutoForm.getFieldValue('dependField');

MichalW commented 8 years ago

I'm working on a big refactoring this package - please few more days of patience :)

MichalW commented 8 years ago

About AutoForm.getFieldValue('dependField'); I think you should create new ReactiveVar for this and use Tracker.autorun

thearabbit commented 8 years ago

I waiting you... Could you example for reactive? My schema:

fieldA: {
type: String,
        label: 'Field A',
        autoform: {
            type: 'universe-select',
            afFieldInput: {
                optionsMethod: 'getA'
            }
        }
}
.........
fieldBDependOnFieldA: {
        type: String,
        label: 'Field B Depend On Field A',
        autoform: {
            type: 'universe-select',
            afFieldInput: {
                optionsMethod: 'getBDependOnFieldA',
                optionsMethodParams: function(){
                  var fieldA= AutoForm.getFieldValue('fieldA');
                  return {fieldA: fieldA};
               }
            }
        }
    }
thearabbit commented 8 years ago

I tried again, the value of fieldA is reactive when it change, but the optionsMethodParams don't pass the new value to server (don't reactive).

MichalW commented 8 years ago

Please check it in the latest version 0.3.1

thearabbit commented 8 years ago

Great, Now I'm updating...

DanceParty commented 7 years ago

When passing the optionsMethodParams, how do I access that value within the server-side method?

DanceParty commented 7 years ago

Figured it out. Thanks.