Closed roypardi closed 6 years ago
Finally figured this out
Working jsfiddle: https://jsfiddle.net/ut8wgtk5/60/
var data = {
view: {
"parent": "bootstrap-edit-horizontal"
},
schema: {
"title": "Test",
"type": "object",
"properties": {
"testColorPicker": {
"type": "string",
"default": "#000000"
},
"testSummernote": {
"type": "string"
},
"testArray": {
"type": "array",
"title": "Array",
"items": {
"title": "Array Item",
"type": "object",
"properties": {
"categorySummernote": {
"type": "string",
},
"categoryColor": {
"type": "string",
"default": "#000000"
}
}
},
}
}
},
options: {
"fields": {
"testColorPicker": {
"type": "colorpicker",
"component": true,
"label": "Test Color",
useAlpha: false
},
"testSummernote": {
"label": "Test Summernote",
"type": "summernote",
"summernote": {
"toolbar": [
['style', ['bold', 'italic', 'underline', 'clear']],
['font', ['strikethrough', 'superscript', 'subscript']],
['fontsize', ['fontsize']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['height', ['height']]
]
}
},
"testArray": {
"toolbarSticky": true,
"actionbarStyle": "bottom",
"label": "Array",
"items": {
"fields": {
"categorySummernote": {
"label": "Test Summernote",
"type": "summernote",
"summernote": {
"toolbar": [
['style', ['bold', 'italic', 'underline', 'clear']],
['font', ['strikethrough', 'superscript', 'subscript']],
['fontsize', ['fontsize']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['height', ['height']]
]
}
},
"categoryColor": {
"type": "colorpicker",
"component": true,
"label": "Test Color"
}
}
}
}
}
}
};
$('#form').alpaca(data);
function getJSON() {
var result = $('#form').alpaca().getValue();
console.log('result', result);
}
I have been trying to use an object with colorpicker field in an array without success. I can make an array of colorpickers – so I have all the correct code hooked up.
I am looking to create an array of objects of varying types. For a simple example:
I've got a stripped down jsfiddle here which demonstrates the issue: I am able to create a colorpicker – but the same code does not work when in an object within an array.
Am I misunderstanding what an array
field
can contain?Example code from the jsfiddle: