In my Grails3 Project on my .gsp I have a Relationship Label followed by an Relationship Groovy textField using the code below:
<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>
I would like to put a "placeholder" text into the textField to display while the field is empty. You can do this on an < input> tag by defining the placeholder value for the input.
My end goal is to make the lable only read "Relationship to Customer:" and to move the "spouse, sibling, stranger, etc." into the textField like a placeholder.
How would I go about this using a < g:textField> ?
Yes you can. Just simply add the placeholder
attribute to the tag and it should include it in the rendered HTML (seem to recall this is the default behavior for all the g
taglibs).
So:
<g:textField placeholder="Your text here" ... />