jsonform / jsonform

Build forms from JSON Schema. Easily template-able. Compatible with Bootstrap 3 out of the box.
https://jsonform.github.io/jsonform/playground/index.html
MIT License
2.72k stars 553 forks source link

Add custom field to fieldset #431

Closed ivMos93 closed 4 months ago

ivMos93 commented 1 year ago

Hi! I created a custom field(mapol) by adding it to a JSONForms object (JSONForm.fieldTypes.mapol). I need to display this field in an accordion fieldset. But I am getting an error. Is there any way to add a custom field to the fieldset?

Error:
`Uncaught (in promise) Error: The JSONForm contains an element that links to an element in the JSON schema (key: "Q_1190") and that should not based on its type ("mapol")
    at formTree.buildFromLayout (jsonform.js?cfd2:3402:1)
    at formTree.eval (jsonform.js?cfd2:3463:1)
    at eval (_optimizeCb.js?1bbb:12:1)
    at Module.each (each.js?f73b:14:1)
    at formTree.buildFromLayout (jsonform.js?cfd2:3459:1)
    at formTree.eval (jsonform.js?cfd2:3208:1)
    at eval (_optimizeCb.js?1bbb:12:1)
    at Module.each (each.js?f73b:14:1)
    at formTree.buildTree (jsonform.js?cfd2:3194:1)
    at formTree.initialize (jsonform.js?cfd2:3174:1)`

My dataParsed object loked like this:

`const jsonFormData = {
  schema: {
    Q_1190: {
      items: [],
      type: "mapol",
      title: "Тест Карта(контур)",
      description: "Выберите контур",
      default: "",
      required: false,
    },
  },
  form: [
    {
      type: "fieldset",
      title: "Test",
      tag: "",
      expandable: true,
      items: [
        {
          key: "Q_1190",
          inlinetitle: null,
          notitle: false,
        },
      ],
    },
    {
      type: "mapol",
      value: "<strong>Aarrr!</strong>",
    },
    {
      type: "submit",
      title: "Записать данные",
      htmlClass: "sub-btn d-none",
    },
  ],
};`

sdetweil: updated with code blocks for readability

sdetweil commented 1 year ago
    {
      type: "mapol",
      value: "<strong>Aarrr!</strong>",
    },

what field do you think you should be showing? you didn't link with the key field maybe

    {
      key: "Q_1190.type",
      value: "<strong>Aarrr!</strong>",
    },

i created a pair field x:y i did that in a separate file and then included the JS as part of my web page https://github.com/jsonform/jsonform/wiki#fields-view-definition

because the default HTML doesn't know how to display that thing

i never specify the type in the form section

stale[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.