File tree Expand file tree Collapse file tree
stories/app/components/VForm Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -221,6 +221,14 @@ const formattedSchema = computed(() => {
221221 return schema
222222})
223223
224+ // REQUIRED FIELDS
225+ const hasRequiredFields = computed (() => {
226+ const required = formattedSchema .value ?.required
227+ if (required === true ) return true
228+
229+ return Array .isArray (required ) && required .length > 0
230+ })
231+
224232// CAPTCHA
225233const captchaInputKey = computed (() => {
226234 const fieldKeys = Object .keys (toValue (formattedSchema .value ?.properties ) || {})
@@ -266,6 +274,13 @@ const isDisabled = computed(() => props.disabled || isPending.value || displayUs
266274 </button >
267275 </dialog >
268276 <slot name =" beforeFields" />
277+ <p
278+ v-if =" hasRequiredFields"
279+ :class =" $style['required-notice']"
280+ class =" text-body-xs"
281+ >
282+ {{ $t('form.required_fields_notice') }}
283+ </p >
269284 <VFormElementFactory
270285 :id =" id "
271286 v-model =" model "
@@ -324,6 +339,11 @@ const isDisabled = computed(() => props.disabled || isPending.value || displayUs
324339 z-index : 1 ;
325340}
326341
342+ .required-notice {
343+ color : rgb (117 117 117 );
344+ margin-block : 16px ;
345+ }
346+
327347.error {
328348 margin-block : 18px ;
329349}
Original file line number Diff line number Diff line change 1+ <script setup lang="ts">
2+ import type { JsonSchemaExtended } from ' ~~/types/json-schema'
3+
4+ const schema = {
5+ title: ' test' ,
6+ type: ' object' ,
7+ properties: {
8+ ' texte' : {
9+ type: ' string' ,
10+ title: ' Texte' ,
11+ },
12+ ' mail' : {
13+ type: ' string' ,
14+ title: ' Votre mail' ,
15+ attr: {
16+ ' data-group' : null ,
17+ },
18+ description: ' mais votre vrai mail' ,
19+ widget: ' email' ,
20+ propertyOrder: 2 ,
21+ },
22+ ' frc-captcha-response' : {
23+ type: ' string' ,
24+ title: ' captcha' ,
25+ },
26+ },
27+ required: [],
28+ }
29+ </script >
30+
31+ <template >
32+ <NuxtStory >
33+ <VForm
34+ :schema =" (schema as JsonSchemaExtended ) "
35+ :gdpr =" false "
36+ novalidate
37+ />
38+ </NuxtStory >
39+ </template >
You can’t perform that action at this time.
0 commit comments