Skip to content

AccountsTemplates.addFields using dynamic values for select #569

@Kunal1985

Description

@Kunal1985

Hi,

I am trying to assign dynamic values to select option as below:
AccountsTemplates.addFields([
{
_id: 'customField',
type: 'select',
displayName: 'Custom Field',
select: custFunct(),
}
]);

custFunct() is a function i have defined as below
var custFunct = function() {
var jsonArr = [];
var jsonObj = {};
jsonObj.text = "Cust1";
jsonObj.value = "cust1";
jsonArr.push(jsonObj);

jsonObj = {};
jsonObj.text = "Cust2";
jsonObj.value = "cust2";
jsonArr.push(jsonObj);

return jsonArr;

};

Post this I am able to see the dropdown getting populated with Cust1 and Cust2 correctly

Now, i have to get these values from one of my collection which is not working as below
var custFunct = function() {
return CustCollection.find().fetch(); // this line gives error that CustCollection is not defined.
};

Kindly suggest how to proceed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions