Skip to content

Commit 252eadb

Browse files
author
Lionel Bijaoui
committed
Custom label, help and hint
- Possibility to use scoped-slot to customise fully how label, help or hint are build - Little change to the structure to make it easy to do this - Heavy use of scoped-slot - Expose `field` object and `getValueFromOption` function
1 parent e054caf commit 252eadb

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

projects/full/app.vue

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,22 @@
2222
<strong>{{ item.error }}</strong>
2323
</div>
2424
</div>
25-
<vue-form-generator :schema="schema" :model="model" :options="formOptions" :multiple="selected.length > 1" ref="form" :is-new-model="isNewModel" @model-updated="modelUpdated" @validated="onValidated"></vue-form-generator>
25+
<vue-form-generator :schema="schema" :model="model" :options="formOptions" :multiple="selected.length > 1" ref="form" :is-new-model="isNewModel" @model-updated="modelUpdated" @validated="onValidated">
26+
<template slot="label" slot-scope="{ field }">
27+
<h1>Custom label : {{ field.label }}</h1>
28+
</template>
29+
<template slot="help" slot-scope="{ field }">
30+
<span v-if='field.help' class="help">
31+
<span @click.prevent="testClick(field.help, $event)">Custom help</span>
32+
<i class="icon"></i>
33+
<!-- <div class="helpText-" v-html='field.help'></div> -->
34+
</span>
35+
</template>
36+
<template slot="hint" slot-scope="{ field, getValueFromOption }">
37+
<span>Custom hint</span>
38+
<div class="hint" v-html="getValueFromOption(field, 'hint', undefined)"></div>
39+
</template>
40+
</vue-form-generator>
2641
</div>
2742
<div class="col-md-6">
2843
<pre v-if="model" v-html="prettyModel"></pre>
@@ -89,6 +104,9 @@ export default {
89104
},
90105
91106
methods: {
107+
testClick(helpText, event) {
108+
console.log(helpText, event);
109+
},
92110
showWarning() {
93111
if (this.$refs.form && this.$refs.form.errors) {
94112
return this.$refs.form.errors.length > 0;

0 commit comments

Comments
 (0)