在我的 .gsp 上的 Grails3 项目中,我有一个关系标签,后跟一个使用以下代码的关系 Groovy 文本字段:
<div class="row top-margin">
<!-- RELATIONSHIP LABEL -->
<div class="col-sm-3" style="margin-bottom: 0.1cm">
<label class="control-label col-sm-6" style="font-weight: normal;" for="customerRelationship">
Relationship to Customer (spouse, sibling, stranger, etc.):
</label>
</div>
<!-- RELATIONSHIP INPUT -->
<div class="col-sm-4" style="margin-bottom: 0.1cm">
<g:textField class="form-control" name="customerRelationship" value="${customerRelationship}"
style="width: 200px;"/>
</div>
</div>
我想将“占位符”文本放入 textField 以在字段为空时显示。您可以通过定义输入的占位符值在 <input> 标记上执行此操作。
我的最终目标是让标签只显示“与客户的关系:”并移动“配偶、兄弟姐妹、陌生人等”。像占位符一样进入文本字段。
我将如何使用 < g:textField> 来解决这个问题?