[英]Bootstrap4 Default Values Within Form
我有以下表格,我正在嘗試使用 bootstrap4 進行自定義。 看起來格式正在工作,但是當我嘗試將編輯表單中的值默認為當前值時,它們會出現在我剛剛創建的表單下方的第二個文本框中。 我將如何調整此代碼,以便在我想要的文本框中默認值?
{{ form.non_field_errors }}
<div class="form-group">
{{ form.employee.errors }}
<label for="{{ form.employee.id_for_label }}"></label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Log the employee">
{{ form.employee }}
<small id="emailHelp" class="form-text text-muted">Who does this individual report to?</small>
</div>
只需將form.employee.value
作為值屬性放入input
標簽。
{{ form.non_field_errors }}
<div class="form-group">
{{ form.employee.errors }}
<label for="{{ form.employee.id_for_label }}"></label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Log the employee" value="{{ form.employee.value }}">
<small id="emailHelp" class="form-text text-muted">Who does this individual report to?</small>
</div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.