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

How to set data for w2field with type="file" in w2form #2579

Open
vinhpt2 opened this issue Nov 6, 2024 · 1 comment
Open

How to set data for w2field with type="file" in w2form #2579

vinhpt2 opened this issue Nov 6, 2024 · 1 comment

Comments

@vinhpt2
Copy link

vinhpt2 commented Nov 6, 2024

I worder how to set value for w2field with type="file" in a w2form. If I set a string or null or "" the w2field go to malfunction - can not interact any more.
(.w2ui-field-helper.w2ui-list have width=0px)

@elfwine
Copy link

elfwine commented Nov 14, 2024

The following setup works for me. Hope this one can helps you.

let form = new w2form({
  name: 'testForm',
  fields: [
    { field: 'name', type: 'text', html: { label: 'Name' } },
    { field: 'inputFile', type: 'file', html: { label: 'Upload File' } }
  ]
});

let data = {
    name: 'Test Name',
    inputFile: [
       { 
          'name': 'test.jpg',
          'type': 'image/jpeg',
          'content': {btob data},
          'size': 19303
       }
   ]
};
form.record = data;

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

2 participants