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

ObjectField.setValue fails to update array value #356

Open
jseabold opened this issue Mar 6, 2016 · 4 comments
Open

ObjectField.setValue fails to update array value #356

jseabold opened this issue Mar 6, 2016 · 4 comments

Comments

@jseabold
Copy link

jseabold commented Mar 6, 2016

I'm trying to set some data for an object in 'postRender'. When the type is an array of objects, the values of the object do not get set.

The reason I'm doing this is that I want to set the default data on a form conditional on the value of another form. Is there some other way to do this?

jsfiddle

Code:

$("#field1").alpaca({
  "schema": {
    "type": "object",
    "properties": {
        "complex": {
          "type": "object",
          "title": "Complex",
          "properties": {
              "property1": {
                  "type": "object",
                  "properties":{
                    "name": {
                       "title": "Name",
                       "type": "string"
                     }
                   }
              },
              "property2": {
                "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "name": {
                         "title": "Step Name",
                         "type": "string"
                      }
                    }

                  }
              }
          }
        }
      }
    },
  "postRender": function(control) {
     complexObj = control.childrenByPropertyId["complex"];
     console.log("post render");
     console.log(complexObj);
     complexObj.setValue({
       'property1': {'name': 'this'},
       'property2': [{'name': 'that'}, {'name': 'those'}]
     })
  }
});
@jseabold
Copy link
Author

jseabold commented Mar 6, 2016

Here's the result

screen shot 2016-03-06 at 12 26 52 pm

@arikw
Copy link

arikw commented Oct 1, 2016

+1
If you'll call the setValue again, say after 200ms, the values will appear correctly.
I guess it has something to do with the creation of child elements, to fit the amount of data items...

@ndbroadbent
Copy link

I just ran into this issue. It creates the new fields but doesn't set the value on text fields. However, it does set the value correctly on dates.

@ndbroadbent
Copy link

@arikw Yes, I think it's to do with the call to Alpaca.nextTick, which runs the callback after a timeout.

darabos pushed a commit to darabos/alpaca that referenced this issue Jan 3, 2019
Items are not getting their values set after they are added.
gitana#356
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants