I have a Classic UI dialog that consists of a multifield & inside that multi-field, I want to create a field that produces a JSON object. If such an xtype does exist, then submitting the field should result in the JCR structure (or CRXDE) saving the data as a JSON object like so: { "base": "...", "hover": "..." }. If a JSON xtype doesn't exist, what's the alternative (except for a multifield which submits one entry, since I'm working with a nested multifield, which means entries are stored inside arrays regardless of the number of entries made)?
Solved! Go to Solution.
Views
Replies
Total Likes
Please keep in mind that the Classic UI is deprecated. You are customizing something that is no longer supported. The reason multifield does not have a JSON format is that the way the data is stored facilitates its manipulation via Sling Models, which is the recommended approach for further working with the data stored in your multifield.
Here, you can learn more about how to use a multifield in Touch UI: https://levelup.gitconnected.com/aem-how-to-use-nested-multifields-in-your-components-using-a-sling-...
Hope this helps
@JustYusaf100x you can check this example given with some customization to store the nested multifield values as json
Please keep in mind that the Classic UI is deprecated. You are customizing something that is no longer supported. The reason multifield does not have a JSON format is that the way the data is stored facilitates its manipulation via Sling Models, which is the recommended approach for further working with the data stored in your multifield.
Here, you can learn more about how to use a multifield in Touch UI: https://levelup.gitconnected.com/aem-how-to-use-nested-multifields-in-your-components-using-a-sling-...
Hope this helps
Hi Esteban,
Thanks for this response. I had to use a workaround (in the clientlib) where I set a property to each multifield item (which in this case, is a JSON object). For example:
var updatedCategories = dialog.getField("./navmenu/shop/categories").getValue().map(function (item) {
var category = JSON.parse(item);
// Setting the property with a single JSON object (stringified)
category.images = category.imagesJson[0] || JSON.stringify({ base: "", hover: "" });
return JSON.stringify(category);
});
dialog.getField("./navmenu/shop/categories").setValue(updatedCategories);
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies