AnsweredAssumed Answered

Dynamically Change of Dropdown Options Runs Twice

Question asked by akc akc on Aug 18, 2014

I am using the Order Line Items module and I want to change/remove certain dropdown options based on the value of a field in the record.

I have read around the issue and tried a few different methods to no avail.

This method seems the closest to what I want

initialize: function (options) {
    this._super('initialize', [options]);
      this.on("render", this.filterStatusDropdown, this);
filterStatusDropdown: function(fields, errors, callback) {
    new_list = {
        1: "Processing",
            3: "Cancelled"
    this.model.fields['status'].options = new_list;

The code seems to run twice. The first time the attributes.status is undefined but the second time it is there. However, it seems that I can only set the dropdown options in the first run but not the second.

I need to add a condition on the status field which determines what new_list consists of but as I don't have the value in the first run I can't check against it. And as mentioned in the second run, setting the dropdown options has no effect.

Can someone please help?

Much appreciated