Skip to content

Commit b694fae

Browse files
author
Lionel Bijaoui
committed
Custom legend block for group
- Possibility to use scoped-slot to customise fully how legend is build - Expose `group` and `groupLegend` in slot prop
1 parent 55b5d9f commit b694fae

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/formGenerator.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@
99
:options="options"
1010
:errors="errors"
1111
:event-bus="eventBus">
12+
<template
13+
slot="group-legend"
14+
slot-scope="{ group, groupLegend }">
15+
<slot
16+
name="group-legend"
17+
:group="group"
18+
:group-legend="groupLegend">
19+
<legend v-if="groupLegend"><span v-html="groupLegend"></span></legend>
20+
</slot>
21+
</template>
1222
<template
1323
slot="group-help"
1424
slot-scope="{ group }">

src/formGroup.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
:is="tag"
44
:class="[groupRowClasses, validationClass]"
55
ref="group">
6-
7-
<legend v-if="groupLegend">{{ groupLegend }}</legend>
6+
<slot
7+
name="group-legend"
8+
:group="group"
9+
:group-legend="groupLegend"></slot>
810
<slot
911
name="group-help"
1012
:group="group"></slot>
@@ -19,6 +21,14 @@
1921
:errors="errors"
2022
:event-bus="eventBus"
2123
:key="index">
24+
<template
25+
slot="group-legend"
26+
slot-scope="slotProps">
27+
<slot
28+
name="group-legend"
29+
:group="slotProps.group"
30+
:group-legend="slotProps.groupLegend"></slot>
31+
</template>
2232
<template
2333
slot="group-help"
2434
slot-scope="slotProps">

0 commit comments

Comments
 (0)