You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I must create a form with nested fields, it works when showing the form and save data to MongoDb, but when i call bind method on form to edit it, only simple fields are binded (as title, code, ...) not the nested.
I don't know if it's a bug or my bad utilisation of 'forms' tool, so, let me share with you some parts of my code.
`
/**
complementary function to add field to form
*/
complementaryFieldsFunction['selectFields'] = function(data){
var formFields = [];
if (typeof data !== 'undefined' && data !== null) {
var values = {name:'values', content:{}};
data.values.forEach(function(item, index){
var keys = Object.keys(item);
keys.forEach(function(item2, index) {
var value = {
code : fields.string({label: "Code value", value: item[item2].code}),
value : fields.string({label: "Value", value: item[item2].value })
}
values.content[index] = value;
});
});
formFields.push(values);
Hi,
I must create a form with nested fields, it works when showing the form and save data to MongoDb, but when i call bind method on form to edit it, only simple fields are binded (as title, code, ...) not the nested.
I don't know if it's a bug or my bad utilisation of 'forms' tool, so, let me share with you some parts of my code.
`
/**
complementary function to add field to form
*/
complementaryFieldsFunction['selectFields'] = function(data){
var formFields = [];
if (typeof data !== 'undefined' && data !== null) {
} else {
formFields.push(
{
name : "values",
content : {
0: {
code: fields.string({label:"Code value"}),
value: fields.string({label:"Value"})
}
}
}
);
}
return formFields;
}
module.exports.getEdit = function(data, type) {
};
`
The idea is :
Create a form witch contains fields depending parameters ( ... function(data, type) { ...).
HTML structure of the form :
`
`
When I call " form = form.bind(data); " with data =
{
"code": "add",
"title": "teqstafsdfsdf",
"type": "select",
"_id": "56c379ab78fa578434cc861e",
"__v": 0,
"mdate": "2016-02-16T19:34:03.952Z",
"cdate": "2016-02-16T19:34:03.951Z",
"values": [
{
"0": {
"code": "b",
"value": "vv"
}
}
]
}
'code', 'title' and 'type' fields are correctly binded (I show the value of each one in the inputs tag) but the field 'values' is empty.
I saw on your git issues 'fields.object( ...' for nested element but haven't found documentation about it.
Do you have any Idea about my problem ?
Thanks in advance!
Raphael
The text was updated successfully, but these errors were encountered: