Skip to content

Commit

Permalink
feat: allow html in label
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanvier committed Apr 26, 2024
1 parent d1be6ae commit f87d636
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@wgr-sa/nuxt-form",
"description": "Form builder for Nuxt",
"version": "0.8.3",
"version": "0.8.4",
"repository": "https://github.com/WGR-SA/nuxt-form.git",
"author": "jeanvier",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion playground/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
name="asdf"
:rules="[ 'isEmail']"
/>
<FormInput label="" type="checkbox" name="tosnlpd" :rules="[{ equals: [true], message: 'coucou' }]" />
<FormInput label='yo <a href="#">ok</a>' type="checkbox" name="tosnlpd" :rules="[{ equals: [true], message: 'coucou' }]" />
<FormInput name="safs" :rules="['isNotEmpty']" />
<FormTextarea name="saffs" :rules="['isNotEmpty']" />
<FormRadio :options="{'O': 'Oui', 'N': 'Non'}" name="yo" laebl="Yo" />
Expand Down
16 changes: 6 additions & 10 deletions src/runtime/components/FormInputContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,15 @@ form.addField(props as FormInput.Container)
</script>

<template>
<div :class="`form__input form__${type ?? 'default'} ${(rules?.includes('isNotEmpty') || props.required) ? 'form--required' : '' }`">
<div
:class="`form__input form__${type ?? 'default'} ${(rules?.includes('isNotEmpty') || props.required) ? 'form--required' : '' }`">
<label
v-if="type !== 'hidden'"
:for="name"
>
{{ label ?? name }}
</label>
:for="name"
v-html="label ?? name"
/>
<slot />
<p
v-for="(error, i) of errors"
:key="i"
class="form__error"
>
<p v-for="(error, i) of errors" :key="i" class="form__error">
{{ error }}
</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/types/builder.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ declare namespace FormBuilder {
[key: string]: any
}

interface FormSubmitter {
export interface FormSubmitter {
form: FormForSubmitter
submit(): Promise<any>
}
Expand Down

0 comments on commit f87d636

Please sign in to comment.