1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-10 21:12:56 +01:00
Radarr/UI/Form/FormBuilder.js
2013-06-13 00:20:33 -07:00

32 lines
973 B
JavaScript

'use strict';
define(['app'], function () {
Handlebars.registerHelper('formBuilder', function (){
var ret = "";
_.each(this.fields, function(field){
ret += NzbDrone.Form.FieldBuilder(field);
});
return new Handlebars.SafeString(ret);
});
NzbDrone.Form.FieldBuilder = function(field) {
if (!field.type) {
return Handlebars.helpers.partial.apply(field, ['Form/TextboxTemplate']);
}
if (field.type === 'password') {
return Handlebars.helpers.partial.apply(field, ['Form/PasswordTemplate']);
}
if (field.type === 'checkbox') {
return Handlebars.helpers.partial.apply(field, ['Form/CheckboxTemplate']);
}
if (field.type === 'select') {
return Handlebars.helpers.partial.apply(field, ['Form/SelectTemplate']);
}
return Handlebars.helpers.partial.apply(field, ['Form/TextboxTemplate']);
};
});