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

wc-form-generator #38

Open
decentropy opened this issue Sep 2, 2020 · 0 comments
Open

wc-form-generator #38

decentropy opened this issue Sep 2, 2020 · 0 comments
Labels
proposal Propose an idea for a new repository

Comments

@decentropy
Copy link

  • wc-form-generator - Drop this component on a web page, to automatically generate forms from JSON schema. You can set and get form data as object.

Usage

<wc-form id="myform"></wc-form>

<script>

//Your form schema... supports: text, dropdown, checkbox
var myformschema = [{
  "id": "test1",
  "label": "helo",
  "type": "text"
},
{
  "id": "test2",
  "label": "welcome",
  "type": "dropdown",
  "choices": [0,2,3]
},
{
  "id": "test3",
  "label": "bye",
  "type": "checkbox",
  "choices": [4,5,6]
}

//Your form data
var myformdata = {"test1":"steve","test2":"3","test3":["4","6"]};

//Draw my form
document.getElementById("myform").drawForm( JSON.parse(myformschema) );

//Fill my form data
document.getElementById("myform").setData( JSON.parse(myformdata) );

//Get my form data
var data = document.getElementById("myform").getData();

</script>
@decentropy decentropy added the proposal Propose an idea for a new repository label Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Propose an idea for a new repository
Projects
None yet
Development

No branches or pull requests

1 participant