<p>Sounds like Matrix is the right field for your situation. The harder part is how you decide to implement this on the front-end.</p>

<p>While your question doesn't say it explicitly, it is tagged <code>plugin-sproutforms</code> so I'm going to base my answer on how to approach this using Sprout Forms.</p>

<p><strong>Option 1: Custom HTML</strong></p>

<p>If you only have a single form, building things out in <a href="http://sprout.barrelstrengthdesign.com/craft-plugins/forms/docs/examples/custom-html" rel="nofollow">Custom HTML</a> might be worth considering.</p>

<p>You can grab the <code>SproutForms_FormModel</code> using the <code>form</code> tag: </p>

<pre><code>{% set form = craft.sproutForms.form('formHandle') %}
</code></pre>

<p>Or use the <a href="http://sprout.barrelstrengthdesign.com/craft-plugins/forms/docs/templating/craft-sproutforms-displaytab" rel="nofollow">displayTab</a> and <a href="http://sprout.barrelstrengthdesign.com/craft-plugins/forms/docs/templating/craft-sproutforms-displayfield" rel="nofollow">displayField</a> tags to output parts of your form that you don't need additional control over.</p>

<p>You would need to build out support for the Matrix Field manually, but Sprout Forms can receive data for a Matrix Field that is built in the <a href="https://straightupcraft.com/articles/craft-cms-field-guide-twig?view=input" rel="nofollow">proper format</a>.</p>

<p><strong>Option 2: Matrix Custom Field Plugin</strong></p>

<p>If you need to reuse your form in multiple places, or have the need to reuse Matrix fields on the front-end, you might consider building a <a href="http://sprout.barrelstrengthdesign.com/craft-plugins/forms/docs/customization/custom-front-end-fields" rel="nofollow">Custom Field</a> for Sprout Forms that adds front-end Matrix support.</p>

<p>There are several examples in the Sprout Fields plugin of how to add front-end Custom Field support for Sprout Forms, it would just require a bit more work to take into account all the scenarios that a Matrix field could present.  Depending on your scenario, you might be able to simplify things and just add support for the fields you need to start off, and add more complexity as the need arose.</p>

CC BY-SA 3.0
2016-04-21T22:47:38.723Z
2016-04-21T22:47:38.723Z
Ben Parizek
<p>I have a situation where a form needs to have the ability add additional fields on the fly. For example, if the user clicks "add cat" a new section/tab appears with the fields to add a new cat. So if the user wanted to add 10 cats to the form they would have that ability without issue.</p>

<p>My first thought was that we could use a matrix field to dynamically add fields, but the field type is unsupported. Any help or ideas would be appreciated.</p>

<p>Example:
<a href="https://i.sstatic.net/dOheP.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/dOheP.png" alt="enter image description here"></a></p>

<plugins><form><plugin-sproutforms>
Creating on-demand Sprout Fields
# Creating on-demand Sprout Fields

(Asked by: username_0 on 2016-04-21)

I have a situation where a form needs to have the ability add additional fields on the fly. For example, if the user clicks "add cat" a new section/tab appears with the fields to add a new cat. So if the user wanted to add 10 cats to the form they would have that ability without issue.

My first thought was that we could use a matrix field to dynamically add fields, but the field type is unsupported. Any help or ideas would be appreciated.

Example:
[![enter image description here](https://i.sstatic.net/dOheP.png)](https://i.sstatic.net/dOheP.png)

**Tags:** plugins, form, plugin-sproutforms

---

## 1 answers

### Answer by username_1 on 2016-04-21. Score: 2

Sounds like Matrix is the right field for your situation. The harder part is how you decide to implement this on the front-end.
While your question doesn't say it explicitly, it is tagged plugin-sproutforms so I'm going to base my answer on how to approach this using Sprout Forms.
Option 1: Custom HTML
If you only have a single form, building things out in Custom HTML might be worth considering.
You can grab the SproutForms_FormModel using the form tag: 
{% set form = craft.sproutForms.form('formHandle') %}

Or use the displayTab and displayField tags to output parts of your form that you don't need additional control over.
You would need to build out support for the Matrix Field manually, but Sprout Forms can receive data for a Matrix Field that is built in the proper format.
Option 2: Matrix Custom Field Plugin
If you need to reuse your form in multiple places, or have the need to reuse Matrix fields on the front-end, you might consider building a Custom Field for Sprout Forms that adds front-end Matrix support.
There are several examples in the Sprout Fields plugin of how to add front-end Custom Field support for Sprout Forms, it would just require a bit more work to take into account all the scenarios that a Matrix field could present.  Depending on your scenario, you might be able to simplify things and just add support for the fields you need to start off, and add more complexity as the need arose.


---

