M
M
Mikhail Petrov2016-11-15 17:55:14
Drupal
Mikhail Petrov, 2016-11-15 17:55:14

How to display several identical fields in a form (Drupal 8)?

Hello. Please help.
There is a utility user XML document that contains data about the meters
of this subscriber. It is necessary to programmatically create a form in which there will be:
the ability to enter new readings.
A subscriber can have several such counters (one subscriber - one XML document).
As a result, it should be that, while parsing this XML document, I start a loop that, finding the counter, takes its ID and forms a form field of the "textfield" type for it. Accordingly, if there are several counters, then there will be several textfields.
Actually a question. How can I programmatically build such a form? After all, each of the received fields needs to be defined somehow (because then, when transferring to the server, it needs to know for which counter what value was entered).
Thank you in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
afi13, 2016-11-16
@mykhaylopetrov

Try https://www.drupal.org/project/double_field
Key in one field, value in another.
Or you can leave the text field, but store it in the database as a string 'key: value' and write a custom widget for the text field that will parse and display two inputs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question