ulion / jsonform

Build forms from JSON Schema. Easily template-able. Compatible with Twitter Bootstrap out of the box.
http://ulion.github.io/jsonform/playground/
MIT License
49 stars 27 forks source link

Title with enums #28

Closed WoodySlum closed 8 years ago

WoodySlum commented 8 years ago

Hi,

Is it possible to set enums title :

gatewayMode: {
                    "type": "number",
                    "title": "Gateway mode [0 : Proxy, 1 : Redirect]",
                    "enum": [
                        0,1
                    ]
                }

I would like to do something like :

gatewayMode: {
                    "type": "number",
                    "title": "Gateway mode",
                    "enum": [
                        {"title":"Proxy, "value":0},
                        {"title":"Redirect, "value":1}
                    ]
                }
ulion commented 8 years ago

sorry, did not get what you want. you can always set title to any string you want.

2016-01-12 20:50 GMT+08:00 Sebastien M. notifications@github.com:

Hi,

Is it possible to set enums title :

gatewayMode: { "type": "number", "title": "Gateway mode [0 : Proxy, 1 : Redirect]", "enum": [ 0,1 ] }

I would like to do something like :

gatewayMode: { "type": "number", "title": "Gateway mode", "enum": [ {"title":"Proxy, "value":0}, {"title":"Redirect, "value":1} ] }

— Reply to this email directly or view it on GitHub https://github.com/ulion/jsonform/issues/28.

Ulion

WoodySlum commented 8 years ago

Ok I agree it was not really clear :) I'm using enum to generate dropdown lists (select html elements). With enum, I can't set a title for each enum values.

In my example above, in the first case the end user can see 0 or 1 in the select box. In the second example - which does not work - I tried to set a title for each enum elements.

To be clear :

What I got :

<option value="0">0</option>
<option value="1">1</option>

What I want :

<option value="0">Proxy</option>
<option value="1">Redirect</option>
ulion commented 8 years ago

that can be done by form element definition certainly. please check the examples.

2016-01-12 22:06 GMT+08:00 Sebastien M. notifications@github.com:

Ok I agree it was not really clear :) I'm using enum to generate dropdown lists (select html elements). With enum, I can't set a title for each enum values.

In my example above, in the first case the end user can see 0 or 1 in the select box. In the second example - which does not work - I tried to set a title for each enum elements.

To be clear :

What I got : 0 1

What I want : Proxy Redirect

— Reply to this email directly or view it on GitHub https://github.com/ulion/jsonform/issues/28#issuecomment-170921600.

Ulion