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 371 forks source link

Boolean data type of the property not working for Radio buttons #712

Open yogirp opened 5 years ago

yogirp commented 5 years ago

I am using the latest version of Alpaca i.e. 1.5.27. I have also tested this issue on the Alpaca website and it's occurring there also. http://www.alpacajs.org/docs/api/forms.html

When I am using the data type as "Boolean" for radio button field, it's not working at all. Below is the schema (properties) : "UseSsl": { "title": "UseSsl", "type": "boolean", "enum": [true, false] }

Options (fields) : "UseSsl": { helper: "Flag determining whether to use an SSL connection or not.", type: "radio", hideNone: true, rightLabel: true }

I have given complete json below which I tested. If I select any option (true or false), it always shows false. But if I change the data type to "string" and make necessary changes, it starts working. Note: Boolean data type for radio button works in Alpaca version 1.5.23.

$("#field1").alpaca({ "schema": { "title": "Your Information", "type": "object", "properties": { "firstName": { "title": "First Name", "type": "string" }, "lastName": { "title": "Last Name", "type": "string" }, "age": { "title": "Age", "type": "integer", "minimum": 0, "maximum": 100 }, "UseSsl": { "title": "UseSsl", "type": "boolean", "enum": [true, false] } } }, "data": {"UseSsl": false}, "options": { "fields": { "UseSsl": { helper: "Flag determining whether to use an SSL connection or not.", type: "radio", hideNone: true, rightLabel: true } }, "form": { "buttons": { "submit": { "click": function() { var value = this.getValue(); alert(JSON.stringify(value, null, " ")); } } } } } });