Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Array-elements are deactivated within selectfieldsets #11

Open
Gitward opened this issue Mar 11, 2015 · 1 comment
Open

Array-elements are deactivated within selectfieldsets #11

Gitward opened this issue Mar 11, 2015 · 1 comment

Comments

@Gitward
Copy link

Gitward commented Mar 11, 2015

I adjusted example.html by adding a select-fieldset that contains an array of objects:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>Getting started with JSON Form</title>
    <link rel="stylesheet" style="text/css" href="deps/opt/bootstrap.css" />
  </head>
  <body>
    <h1>Getting started with JSON Form</h1>
    <form></form>
    <div id="res" class="alert"></div>
    <script type="text/javascript" src="deps/jquery.min.js"></script>
    <script type="text/javascript" src="deps/underscore.js"></script>
    <script type="text/javascript" src="deps/opt/jsv.js"></script>
    <script type="text/javascript" src="lib/jsonform.js"></script>
    <script type="text/javascript">
      $('form').jsonForm({
        schema: {
          name: {
            type: 'string',
            title: 'Name',
            required: true
          },
          age: {
            type: 'number',
            title: 'Age'
          },
          personality: {
            "type": "string",
            "title": "personality",
            "enum": ["active", "lazy"],
            "required": true,
            "default": "active"
          },
          hobbies: {
            type: 'array',
            "minItems": 2,
            "items": {
              "type": "object",
              "properties": {
                name: {
                  "type": "string",
                  "title": "Hobby",
                  "default": "Soccer"
                },
                since: {
                  "type": "string",
                  "title": "Active since",
                  "default": "2000"
                }
              }
            }
          }
        },
        "form": [
          "name",
          "age",
          {
            "type": "selectfieldset",
            "key": "personality",
            "title": "pers",
            "items": [
              {
                "type": "fieldset",
                "htmlClass": "some-html-class",
                "title": "Your hobbies",
                "legend": "Enter your hobbies",
                "items": ["hobbies"]
              },
              {"legend": "Lazy people don't have hobbies"},
            ]
          }
        ],
        onSubmit: function (errors, values) {
          if (errors) {
            $('#res').html('<p>I beg your pardon?</p>');
          }
          else {
            $('#res').html('<p>Hello ' + values.name + '.' +
              (values.age ? '<br/>You are ' + values.age + '.' : '') +
              '</p>');
          }
        }
      });
    </script>
  </body>
</html>

Unfortunately all elements but the first are deactivated. When adding new elements using the +, those elements are active. After switching the personality from active->lazy->active, newly added elements are also deactivated.

jf_1
jf_2
jf_3
jf_4

@Gitward
Copy link
Author

Gitward commented Mar 11, 2015

This error seems to be there from the beginning on:

196486e The 'selectfieldset' field type may now be linked to a schema key.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant