我做了一个表格,并有实体 我想制作,依赖于下拉选择显示一个实体的不同形式样式
例如在JS
中var firsttype=<div class="form-row form-group">
<div class="col-sm-3 col-md-3">
{{ form_label(form.line1, "Passport Line 1", {"label_attr": {"class": "control-label"} }) }}
</div>
<div class="col-sm-3 col-md-3 controls">
{{ form_errors(form.line1) }}
{{ form_widget(form.line1) }}
</div>
</div>
<div class="form-row form-group ">
<div class="col-sm-3 col-md-3">
{{ form_label(form.line2, "Passport Line 2", {"label_attr": {"class": "control-label"} }) }}
</div>
<div class="col-sm-3 col-md-3 controls">
{{ form_errors(form.line2) }}
{{ form_widget(form.line2) }}
</div>
</div>
<div class="form-row form-group ">
<div class="col-sm-3 col-md-3">
{{ form_label(form.nameOnDocument, "Name on Document", {"label_attr": {"class": "control-label"} }) }}
</div>
<div class="col-sm-3 col-md-3 controls">
{{ form_errors(form.nameOnDocument) }}
{{ form_widget(form.nameOnDocument, {"attr" : { "class": "form-control"} }) }}
</div>
<div class="col-sm-3 col-md-2 col-md-offset-1">
{{ form_label(form.expireDate, "Expiry Date", {"label_attr": {"class": "control-label"} }) }}
</div>
<div class="col-sm-3 col-md-3 controls">
{{ form_errors(form.expireDate) }}
{{ form_widget(form.expireDate, {"attr" : { "class": "form-control" } }) }}
</div>
</div>
这种不同的风格和改变形式的不同风格,取决于下拉列表
$('.form_type').html(firsttype);
因为如果选择1,你需要感受所有信息,如果选择2,只需添加简单信息