Using Django, I want to store a list of textfields that is initially empty but when you click a button it will add a text field. a good example is the add attachment in email, except instead of adding files i just want to add textfields.
Then once I have this feature setup I would like to be able to add all textfields into one textfield to allow a user to edit all textfields at one time, then parse them back into the original text field.
is this possible?
Thank you
cooper
If you don’t need to add an unlimited number of inputs, my recommendation would be to use the combination of a custom MultiValueField and MultiWidget, and show/hide the fields you might want to initially hide.
You’ll be able to leverage the built-in compress and decompress methods to take the values and split them back out to individual inputs (you’d have to split the text on a delimiter) and then take the separate values and compress them back into one.
If you need to be able to add an unlimited number of fields, and parse them back into one value, I would use a formset to hold the values, which you can concatenate the values of back into another field if you need, or just show in a loop, if all you need is to display them as if they were one field.