Skip to content

Commit fcb406a

Browse files
committed
feat(hint): implement field hints
1 parent bf9713c commit fcb406a

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/FormGroup.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ const shouldHaveLabel = computed(() => {
5858
/>
5959
</div>
6060

61+
<div v-if="fieldComponent && fieldComponent.hint" class="hints">
62+
<span class="hint">{{ fieldComponent.hint }}</span>
63+
</div>
64+
6165
<div v-if="fieldComponent && fieldComponent.errors.length" class="errors help-block">
6266
<template v-for="error in fieldComponent.errors" :key="error">
6367
<span class="error">{{ error }}</span> <br>
@@ -74,6 +78,11 @@ const shouldHaveLabel = computed(() => {
7478
margin-left: .2rem;
7579
}
7680
81+
.hint {
82+
color: gray;
83+
font-size: 90%;
84+
}
85+
7786
.errors {
7887
color: red;
7988
font-size: .8rem;

src/mixins/abstractField.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,17 @@ export default {
235235
*/
236236
isReadOnly () {
237237
return this.determineDynamicAttribute('readonly')
238-
}
238+
},
239239

240+
/**
241+
* Compute the hint to be displayed underneath the field input element.
242+
* Should return a string value.
243+
*
244+
* @returns {String}
245+
*/
246+
hint () {
247+
return this.determineDynamicAttribute('hint')
248+
}
240249

241250
}
242251

0 commit comments

Comments
 (0)