2015-11-04 80 views
1

我正在试验autoforms和html表中的数组字段。到目前为止,我可以修改行并删除它们,但在解决如何添加新行时遇到问题。添加按钮似乎没有做任何事情。使用autoform和html表添加新行

我迄今为止代码:

{{#autoForm id="eventDatesForm" type="update" collection="Events" doc=this buttonContent="Save"}} 

     <h2>Event Dates</h2> 
     {{> afQuickField name="timezone"}} 
     <table class="table table-bordered table-hover table-condensed"> 
     <thead> 
      <tr> 
      <th>Slice Start</th> 
      <th>Slice End</th> 
      <th><button type="button" class="btn btn-primary autoform-add-item" data-autoform-field="{{this.atts.name}}" data-autoform-minCount="{{this.atts.minCount}}" data-autoform-maxCount="{{this.atts.maxCount}}"><span class="glyphicon glyphicon-plus"></span></button></th> 
      </tr> 
     </thead> 
     {{#afEachArrayItem name="WiFiOffloadSettings"}} 
     <tbody> 
     <tr> 
      <td>{{> afFieldInput name=this.current.offloadSliceStart type=datetime}}</td> 
      <td>{{> afFieldInput name=this.current.offloadSliceEnd type=datetime}}</td> 
      <td><button type="button" class="btn btn-danger btn-sm autoform-remove-item"><span class="glyphicon glyphicon-minus"></span></button></td> 
     </tr> 
     </tbody> 
    {{/afEachArrayItem}} 
    </table> 
    <button type="submit" class="btn btn-primary">Save</button> 
    {{/autoForm}} 

回答

1

在Add按钮,尝试使用名称 “WiFiOffloadSettings”。

也就是说,

<button type="button" class="btn btn-primary autoform-add-item" 
data-autoform-field="WiFiOffloadSettings" data-autoform-minCount=" 
{{this.atts.minCount}}" data-autoform-maxCount= {this.atts.maxCount}}"> 
<span class="glyphicon glyphicon-plus"></span> </button>