I have been playing around with AlloyUI form builder but I can't find how to get the data of the form I have been editing. I looked in the doc, the code... am I blind ? :-)
Thanks! Chris
Persisting the generated form to be represented later is something you must do on your own, so you can decide the structure that better suits your needs. The properties you're looking for are stored in the fields of the form.
A rough idea could be to iterate through the fields
array and extract the information you want. For example:
var formXML = '<root>';
formBuilder.get('fields').each(
function(item, index, collection) {
var dataType = item.get('dataType'),
indexType = item.get('indexType'),
label = item.get('label'),
multiple = item.get('multiple'),
name = item.get('name'),
options = item.get('options'),
readOnly = item.get('readOnly'),
repeatable = item.get('repeatable'),
required = item.get('required'),
showLabel = item.get('showLabel'),
type = item.get('type'),
width = item.get('width');
var fieldXML = '<field>';
fieldXML += '<type>' + dataType + '</type>';
fieldXML += '<name>' + name + '</name>';
fieldXML += '<required>' + required + '</required>';
fieldXML += '</field>';
}
}
formXML += '</root>';
Then, you can save that xml and use it later to replicate the form you edited from other parts of your site.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With