I'm on magnolia 6.2.15 and I need to generate data from some fields that users insert in a content detail subapp. I thought about creating a subclass of magnolia "SaveDetailSubAppAction", in the "execute" method to do the job. I can retrieve fields value but, how can I generate new fields data values and insert that in the form before validation and commit to jcr datasource?
Asked
Active
Viewed 189 times
1 Answers
1
Well you can't. Or rather you shouldn't. The form is means for user to enter the data. If you create data programatically, you either send it directly to the datasource or store it directly on the node that datasource operates on.
If you want to show generated data to user for approval prior saving, then you need to create custom field that would have the place for extra input and would react on user generated input directly prior to saving content.

Jan
- 4,369
- 14
- 25
-
Thanx for your answer. What i am trying to do is generate the "name" field from 2 other fields. I would like the "name" field to be readonly – Massimo Luise Jan 31 '22 at 08:04
-
Sure, then just generate it directly in the save action, but don't try to create it as a field. Just generate it and write on the node backing the dialog (ie, extend the default save action, call the super.execute() first and then take this node that was created and add the name property to it ( or rename the node itself if this is what you want to do). – Jan Feb 01 '22 at 13:09