json-schema-form/angular-schema-form

Send Raw JSON data

ncrocfer opened this issue · 4 comments

Hello,

I'm trying to allow my users to send raw JSON in a field, using the CodeMirror extension (https://github.com/philippbosch/angular-schema-form-ui-codemirror).

Unfortunately the data is not validated as a valid JSON :
codemirror_object

Here is my schema :

{
    'type': 'object',
    'additionalProperties': False,
    'properties': {
        'query': {
            'title': 'Your OpenTSDB query',
            'type': 'object',
            'description': 'Lorem ipsum...'
        }
    }
}

And my form :

{
    "key": "query",
    "type": "codemirror",
    "codemirrorOptions": {
          "lineNumbers": true,
          "mode": "javascript",
          "theme": "twilight"
    }
}

When I change the type for string type, the JS validation is ok but as I'm also using the schema in the Python backend, it's also failing :)

Thank you for your help, and thanks also for this great module !

I don't know that extension, have you contact the creator and asked for some input or a fix?

Oups, no sorry I misspoke. The problem is not the extension, I have the same behaviour with a simple "textarea" type in the form definition.

I should not have talked about codemirror :)

My question is : how to send raw JSON data please ?

The easiest way would be to use an extension applied to a textarea that then updates the model. It wouldn't be hard to do, similar to writing a normal bit of code in angular only you turn it into a ccomponent, the framework is ultimately an angular template manager after all. If you take a look at the calculate extension in the example/add-on folder you can see how you can add whatever you like in a template and then add any required directives to it. If you want to start with the template used for a text area then you can manipulate it to do what you want it to.

Ok great, I'll do it ! Thanks for your answer :)