我可以在其他表单标签中编写表单标签吗?

时间:2014-10-16 13:07:22

标签: jquery jquery-ui underscore.js

我可以在其他表格标签中写表格标签吗?实际上我的要求是实现文件上传。这里我们使用下划线js模板,我们将所有项目保存为一个表单。 在表单中添加上传代码后,我无法完成文件上传功能。请查看代码下方的代码。

<script type="text/template"><div class="container"></br></br>
<% _.each(forms, function(form){ %>
<form id="<%= formId(form) %>" name="<%= formCaption(form) %>">
    <%_.each(form.layout.grid,  function(grid){
         _.each(grid.columns, function(column){ 
            var dcLayoutInfo = dataControlLayoutInfo(column);
            var dcInfo = dataControlInfo(form.datacontrols,dcLayoutInfo.datacontrol);
            var datacontrols = formDatacontrols(form) 
             _.each(datacontrols, function(datacontrol){ 
                if(dcInfo.id == datacontrol.id){%>
                    <div class="form-group"><div class="row datacontrol" id="<%=datacontrolId(datacontrol)%>">
                    <% _.each(datacontrol.layout.grid, function(grid){ 
                     _.each(grid.columns, function(column){ 
                            var datatypes = datacontrolDatatypes(datacontrol);
                            var datatypeLayoutInfo = dataTypeLayoutInfo(column);
                            var datatypeInfo = dataTypeInfo(datatypes,datatypeLayoutInfo.datatype); 
                        if("label" == datatypeInfo.dataType){ %>
                            <div class="col-sm-2" ><label class="input-sm control-label lableId" id="<%= datatypeInfo.id %>" data-type="label"><%=datatypeInfo.caption%></label></div>
                        <%}else if("text" == datatypeInfo.dataType){%>
                            <!--div class="col-sm-8 p-r-0"><input id="<%= datatypeInfo.id %>" class="form-control input-sm selected datatype" type="<%= datatypeInfo.type %>" data-type="text"/></div-->
                            <div class="col-sm-5"><input id="<%= datatypeInfo.id %>" type="<%= datatypeInfo.type %>" class="form-control input-sm selected datatype" data-type="text"></div>
                        <%}else if("progress" == datatypeInfo.dataType){%>
                            <!--div class="col-sm-10"><div class="progress slider"><div id="<%= datatypeInfo.id %>" class="progress-bar datatype" data-type="progress" role="progressbar" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100" style="width:25%"/>
                            </div></div>-->
                        <div class="col-md-5 m-t-4"><div class="slider-container"><input id="<%= datatypeInfo.id %>" type="<%= datatypeInfo.type %>" class="input-slider datatype" data-slider-min="-20" data-slider-max="150" data-slider-value="0" data-type="progress"></div></div>
                        <!--date control -->
                        <%}else if("datepicker" == datatypeInfo.dataType && datatypeInfo.range==false){%>
                            <div class="col-sm-1 m-b-15 m-r-5"><div class="input-icon datetime-pick date-only"><input placeholder="MM/DD/YYYY" type="<%= datatypeInfo.type %>" class="form-control input-sm datatype" id="<%= datatypeInfo.id %>" data-type="datepicker" range="<%= datatypeInfo.range %>">
                                    <span class="add-on-right "><i class="fa fa-calendar"></i></span></div></div><div class="col-sm-1 m-b-15">
                                        <div class="input-icon datetime-pick time-only"><input placeholder="HH:MM" type="<%= datatypeInfo.type %>" class="form-control input-sm datatype" data-format="hh:mm:ss" id="<%= datatypeInfo.id %>">
                            <span class="add-on-right "><i class="fa fa-clock-o"></i></span></div></div>
                        <%}else if("datepicker" == datatypeInfo.dataType && datatypeInfo.range==true){%>
                        <div class="col-sm-1 m-b-15 m-r-5"><div class="input-icon datetime-pick date-only">
                            <input placeholder="MM/DD/YYYY" type="<%= datatypeInfo.type %>" class="form-control input-sm datatype" id="<%= datatypeInfo.id %>" data-type="datepicker" range="<%= datatypeInfo.range %>">
                                <span class="add-on-right "><i class="fa fa-calendar"></i></span></div></div><div class="col-sm-1 m-b-15">
                                    <div class="input-icon datetime-pick time-only"><input placeholder="HH:MM" type="<%= datatypeInfo.type %>" class="form-control input-sm" data-format="hh:mm:ss" id="<%= datatypeInfo.id %>">
                                <span class="add-on-right "><i class="fa fa-clock-o"></i></span></div></div>
                            <div><span class="add-on-right  pull-left"><i class="fa fa-minus p-t-10"></i></span></div><div class="col-sm-1 m-b-15 pull-left">
                        <div class="input-icon datetime-pick date-only"><input placeholder="MM/DD/YYYY" type="<%= datatypeInfo.type %>" class="form-control input-sm enddate" id="<%= datatypeInfo.id %>" data-type="datepicker">
                            <span class="add-on-right "><i class="fa fa-calendar" id="calendar"></i></span></div></div>
                                <div class="col-sm-1 m-b-15"><div class="input-icon datetime-pick time-only"><input placeholder="HH:MM" type="<%= datatypeInfo.type %>" class="form-control input-sm " data-format="hh:mm:ss" id="<%= datatypeInfo.id %>">
                        <span class="add-on-right"><i class="fa fa-clock-o"></i></span></div></div>
                        <!--category control -->    
                        <%}else if("category" == datatypeInfo.dataType){%>
                            <div class="btn-group datatype" id="<%= datatypeInfo.id %>" data-type="category">
                                <% _.each(datatypeInfo.values, function(categoryObj){ %>
                                    <li class="onselectedCategory btn btn-gr-gray btn-sm m-r-20 ctg" data-id="<%= categoryObj.value %>"><%= categoryObj.value %></li>
                                <% }); %>                                   
                            </div>
                        <!--contact control -->
                        <%}else if("contactpicker" == datatypeInfo.dataType){%>
                            <div class="col-md-10"><div class="input-group"><span class="input-group-addon"><i class="fa fa-user"></i></span><input type="<%= datatypeInfo.type %>" class="form-control datatype" id="<%= datatypeInfo.id %>" name="<%= datatypeInfo.id %>" data-type="text"/><span class="input-group-addon"><i class="fa fa-book"></i></span></div></div>
                        <!--category list control -->
                        <%}else if("fieldset" == datatypeInfo.dataType){%>
                            <div class="col-md-5"><div class="container datatype" data-type="fieldset" id="<%= datatypeInfo.id %>">
                            <select type="<%= datatypeInfo.type %>" class="form-control multiselect btn-group"  id="categoryList" style="width: 400px;" multiple="multiple">
                                <% _.each(datatypeInfo.values, function(categoryObj){ %>
                                    <optgroup>
                                        <option value="<%= datatypeInfo.values %>"><%= categoryObj.value %></option>
                                    </optgroup>
                                <% }); %>   
                                </select>
                            </div>
                        </div>
                    <%}else if("file" == datatypeInfo.dataType){%>
                        <div class="col-sm-9 fileupload fileupload-new input-icon selected datatype" id="<%= datatypeInfo.id %>" data-provides="fileupload" data-type="file">
                            <form id="upload" name="upload" action="api/v1/resources" method="POST" type="<%= datatypeInfo.type %>" enctype="multipart/form-data">
                                <span class="btn btn-file btn-sm btn-alt">
                                    <span class="fileupload-new p-l-15">Add Image...</span>
                                        <span class="fileupload-exists p-l-15">Change</span>
                                    <input id="file" type="file" name="file"/><br>
                                <input id="json" type="hidden" name="json"> 
                            <span class="add-on p-t-0">
                        <i class="icon"><b>&#61697;</b></i>
                    </span>
                </span>
                    <span class="fileupload-preview"></span>
                        <a href="#" class="close close-pic fileupload-exists" data-dismiss="fileupload">
    </a>
<button type="submit" class="btn btn-sm submit" id="imageUpload">Upload</button>
</form>
    <div id="message"></div>
        <div id="resource"></div>
    </div>
    <%}});  
    });%>   
</div></div>
    <%}     
});
    });
});
});%>
</br>
 <div class="row">
    <div class="col-md-2">
    </div>
    <div class="col-md-10">
        <div align="center">
        <button type="submit" class="btn btn-primary" id="itemSave"><i class="fa fa-check"/>  Submit</button>
            &nbsp;&nbsp;&nbsp;&nbsp;
        <button id="cancel" type="submit" class="btn btn-primary backToRecodDetails"><i class="fa fa-times"/> Cancel</button>
        <div>
    </div>
  </div>
  <input id="hidden_appid" type="hidden" value= "<%=id%>" data-appname="<%=caption%>">  
  <input id="hidden_spaceid" type="hidden" value= "<%=spaceId%>">   
</form>    

1 个答案:

答案 0 :(得分:4)

没有。你不能嵌套表格。它在the specification

  

内容模型:流内容,但没有表单元素后代。