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

formBuilder.setData() doesn't work for custom numeric attributes #945

Bill-Dagg opened this issue May 10, 2019 · 1 comment


None yet
2 participants
Copy link

commented May 10, 2019


I've defined a custom control attribute as follows:

typeUserAttrs: {
  button: {
    audioIndex: {
      label: 'Audio index',
      value: 1

In the formBuilder edit panel, this renders correctly as an input of type "number" and any value specified is properly set in the control's formData:

    "type": "button",
    "label": "button1",
    "name": "button1",
    "audioIndex": "14"

However, when the formData JSON is saved and re-loaded using formBuilder.setData(), the custom field's value (14, in the example above) is not set for the custom attribute's edit panel field -- the input field is empty.

I've traced this down to a problem in the numberAttribute() function when it is used for custom attributes. The issue is with the following line:

const attrVal = attrs[attribute];

When called from processTypeUserAttrs(), attribute is "audioIndex" and attrs looks like this:

  label: "Audio index",
  value: "14"

Since there is no "audioIndex" attribute in attrs, attrVal is undefined and the value is not restored to the input field.

I was able to fix this by changing the above line to the following:

const attrVal = attrs[attribute] || attrs.value;

Environment Details:

  • formBuilder Version: 3.1.3
  • Browser: Chrome
  • OS: Win10

Expected Behavior

Custom numeric attributes are re-loaded by formBuilder.setData()

Actual Behavior

They're not.

Steps to Reproduce

See above.

kevinchappell added a commit that referenced this issue May 27, 2019

kevinchappell added a commit that referenced this issue May 27, 2019

kevinchappell pushed a commit that referenced this issue May 27, 2019

chore(release): 3.2.4 [skip ci]
## [3.2.4](v3.2.3...v3.2.4) (2019-05-27)

### Bug Fixes

* npm audit ([d7d7535](d7d7535))
* numeric value preservation ([9e4de4f](9e4de4f)), closes [#945](#945)

This comment has been minimized.

Copy link

commented May 27, 2019

🎉 This issue has been resolved in version 3.2.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.