gitana / alpaca

Alpaca provides the easiest way to generate interactive HTML5 forms for web and mobile applications. It uses JSON Schema and simple Handlebars templates to generate great looking, dynamic user interfaces on top of Twitter Bootstrap, jQuery UI, jQuery Mobile and HTML5.
http://www.alpacajs.org
Other
1.29k stars 370 forks source link

checkbox/radio inputs should not require "enum" #239

Open billbarsch opened 9 years ago

billbarsch commented 9 years ago

Something like this should be possible:

$("#field3").alpaca({
    "data": "green",
    "options": {
        "type": "radio",
        "label": "Favorite Color"
    },
    "schema": {
        "type": "string"
    }
});

to create radio/checkbox inputs like tihs:

<input type="radio" name="name" value="green">

The enum requeriment should be optional.

Ex: I have a alpaca table field to show some data like "my email box" If I need to put a checkbox to "select" my "emails", and put the database "id" at the checkbox "value", I can't do this because checkboxes requires enum.

uzquiano commented 9 years ago

That's interesting. I like the way you think. That certainly would be easier.

However... it seems to go against the design of Alpaca (as a forms generator around JSON schema). Wherein 100% of the form schema validation (allowed values, etc) is derived from the underlying JSON schema. In this case, the schema doesn't say anything about the allowed values. The data provided shouldn't necessarily force the schema, if you know what I mean.

Need to give it some thought as I think it'd be much easier. But it might encourage some practices that deviate from what is ideally supported by the tool.

What do you think? Cool idea and apart from the JSON schema mindset, I'm otherwise in agreement.