Is it possible to add dynamic input text fields on user request in the edit modal window?
Is it possible to add dynamic input text fields on user request in the edit modal window?
itxuser
Posts: 18Questions: 5Answers: 0
I would like to make a way for a user to be able to add an input text field as needed in my editable form. For example, say I am gathering information about their family members, need a way to add 1, 2, 3, or more input text fields as needed. I know this will need a 1:M relationship in the database, but was seeing if their was already a way for this too work with this library. Thanks!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Can someone please look at this and see if there is an easy to do this using the datatables editor library? Thanks!
You can dynamically add fields with this API:
https://editor.datatables.net/reference/api/add()
Kevin
The
add()
method looks promising, but how do I get it to work and save to the database using this datatables editor? I can see this working similar to theuploadMany()
method for files, that after someone enters some text in the input field, it would show what they added just below it in some kind of list, and they could add another, and another. I just wouldn't need to import files for this. Probably need to setup some kinds of array on the input, and use the mjoin in my datatables editor php server file most likely. Just not sure how to get started on this. Thanks!To have this work with
MJoin
on the server-side I think you'd almost certainly need to create a new custom field type plug-in.Basically you need the field type to be able to add and remove fields dynamically and give the values entered as an array to the server. Currently only the
uploadMany
field type that you mention has that ability in the built in options.It is something I'm interested in generalising and making available in future, but there isn't a built in option yet and as I say, it would need a custom field type.
Allan