title: "Neither BindingResult nor plain target object" error using Spring form tag while repeating form field
body: <p>This is the part of my form in the jsp page which I want to repeat upon the press of the "Add Field" button:</p>
  
  <pre><code>&lt;div style="font-weight:bold"&gt;Choose Form Fields:&lt;/div&gt;
  &lt;table id="tbl-formfields" class="table vertical-align table-condensed" &gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th width="10%"&gt;Display Order&lt;/th&gt;
              &lt;th width="33%"&gt;Field&lt;/th&gt;
              &lt;th width="33%"&gt;Input Type&lt;/th&gt;
              &lt;th width="12%"&gt;Make Required&lt;/th&gt;
              &lt;th width="12%"&gt;Action&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody id="tbody"&gt;
          &lt;tr id="tr-formField"&gt;
              &lt;td&gt;
                  &lt;form:select path="formOptionDisplayOrder" name="formOptionDisplayOrder" id="formOptionDisplayOrder"&gt;
                      &lt;c:forEach begin="0" end="9" step="1" varStatus="loop"&gt;
                          &lt;form:option value="${loop.count}"&gt;&lt;c:out value="${loop.count}"/&gt;&lt;/form:option&gt;
                      &lt;/c:forEach&gt;
                  &lt;/form:select&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;form:select path="formFieldName" name="formFieldName" id="formFieldName"&gt;
                      &lt;option value=""&gt;-------------------------------------&lt;/option&gt;
                      &lt;c:forEach var="ff" items="${formFields}"&gt;
                          &lt;form:option value="${ff.formFieldId}"&gt;${ff.formFieldName}&lt;/form:option&gt;
                      &lt;/c:forEach&gt;
                  &lt;/form:select&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;div&gt;
                      &lt;span&gt;
                          &lt;form:select path="formOptionType" name="formOptionType" id="formOptionType"&gt;
                              &lt;form:option value=""&gt;-------------------------------------&lt;/form:option&gt;
                              &lt;c:forEach var="ot" items="${optTypes}"&gt;
                                  &lt;c:set var="optValue" value="${fn:split(ot,' ')}"/&gt;
                                  &lt;form:option value="${fn:toLowerCase(optValue[0])}"&gt;${ot}&lt;/form:option&gt;
                              &lt;/c:forEach&gt;
                          &lt;/form:select&gt;
                      &lt;/span&gt;
                  &lt;/div&gt;
                  &lt;div id="block-optionsInput" style="display:none"&gt;
                      &lt;label&gt;Options:&lt;/label&gt;&lt;br&gt;
                      &lt;form:input path="fieldOptions" id="options" type="text" name="fieldOptions" data-role="tagsinput" value=""/&gt;&lt;!-- value="Male,Female"/&gt;--&gt;
                  &lt;/div&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;label&gt;&lt;form:checkbox  path="fieldRequired" name="fieldRequired" value="true"/&gt; Required&lt;/label&gt;
              &lt;/td&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;div&gt;
      &lt;button type="button" id="btn-addfield" class="btn btn-primary"&gt;
          &lt;span class="glyphicon glyphicon-plus"&gt;&lt;/span&gt; Add Field
      &lt;/button&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And the javascript/jQuery code to repeat this field is:</p>
  
  <pre><code>//****Repeat form field block****
      var repeatBlock = "#tbody";
      var repeatText = '&lt;td&gt;\n\
              &lt;form:select path="formOptionDisplayOrder" name="formOptionDisplayOrder" id="formOptionDisplayOrder"&gt;\n\
                  &lt;c:forEach begin="0" end="9" step="1" varStatus="loop"&gt;\n\
                      &lt;form:option value="${loop.count}"&gt;&lt;c:out value="${loop.count}"/&gt;&lt;/form:option&gt;\n\
                  &lt;/c:forEach&gt;\n\
              &lt;/form:select&gt;\n\
          &lt;/td&gt;\n\
          &lt;td&gt;\n\
              &lt;form:select path="formFieldName" name="formFieldName"&gt;\n\
                  &lt;form:option value=""&gt;-------------------------------------&lt;/form:option&gt;\n\
                  &lt;c:forEach var="ff" items="${formFields}"&gt;\n\
                      &lt;form:option value="${ff.formFieldId}"&gt;${ff.formFieldName}&lt;/form:option&gt;\n\
                  &lt;/c:forEach&gt;\n\
              &lt;/form:select&gt;&lt;/td&gt;\n\
          &lt;td&gt;\n\
              &lt;form:select path="formOptionType" class="optType" name="formOptionType"&gt;\n\
                  &lt;form:option value=""&gt;-------------------------------------&lt;/form:option&gt;\n\
                  &lt;c:forEach var="ot" items="${optTypes}"&gt;\n\
                      &lt;c:set var="optValue" value="${fn:split(ot,' ')}"/&gt;\n\
                      &lt;form:option value="${fn:toLowerCase(optValue[0])}"&gt;${ot}&lt;/form:option&gt;\n\
                  &lt;/c:forEach&gt;\n\
              &lt;/form:select&gt;\n\
              &lt;div class="optBlock" style="display:none"&gt;\n\
                  &lt;label&gt;Options:&lt;/label&gt;&lt;br&gt;\n\
                  &lt;form:input path= "fieldOptions" class="optInput" type="text" name="fieldOptions" data-role="tagsinput" value=""/&gt;\n\
              &lt;/div&gt;\n\
          &lt;/td&gt;\n\
          &lt;td&gt;&lt;label&gt;&lt;form:checkbox path="fieldRequired" name="fieldRequired" value="true"/&gt; Required&lt;/label&gt;&lt;/td&gt;\n\
          &lt;td&gt;&lt;a href="javascript:void(0)" class="removeField" style="color:red" title="Remove this field"&gt;\n\
              &lt;span class="glyphicon glyphicon-remove"&gt;&lt;/span&gt;&lt;/a&gt;\n\
          &lt;/td&gt;&lt;/tr&gt;';
      $("#btn-addfield").click(function (e) {
          e.preventDefault();
          $(repeatBlock).append('&lt;tr class="trRepeat"&gt;' + repeatText);
      });
      $(repeatBlock).on('click', '.removeField', function (e) {
          e.preventDefault();
          $(this).parent().parent().remove();
      });
  </code></pre>
  
  <p>When I add the Spring form block on the javascript part, I get the following error:</p>
  
  <p><code>Neither BindingResult nor plain target object for bean name 'formOptionDisplayOrder' available as request attribute</code></p>
  
  <p>The page loads fine if I use a simple HTML form block on the js part, but data from the subsequent repeated fields is not sent to the controller. Is adding the Spring form block not allowed? And is there a workaround?</p>
  
  <p>Also, is it possible to declare the repeatable properties of an object as arrays/lists and loop for the total number of fields on the controller and set the values?</p>
  
  <p>Thanks in advance.</p>