In the field ui, we can create a textfield with unlimited values. Which has button of add another, which when clicked added another field with a remove button.

I want the same functionality in my custom form. How will I create a textfield with unlimited values? enter image description here


2 Answers 2


Here is a nice article on how to do it using Form API http://rapiddg.com/blog/use-ajax-support-multiple-item-values-custom-drupal-7-forms

Hope this helps.

  • How to do the same in D8?
    – Cool
    Jul 22, 2017 at 14:48

Use Ajax. Here you have an example where an Ajax action will change the values of a select field.

Change the disabled status of a form element via Ajax

You can adapt the code in order to add fields instead of just replacing them. The method would be similar to that done with simple pure AJAX, but you will benefit from using the Drupal FORM API.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.