PluginProbe
The Innovative Form Builder – IvyForms / 0.3.1
The Innovative Form Builder – IvyForms v0.3.1
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / frontend / src / views / public / fields / EmailFormField.vue

EmailFormField.vue in The Innovative Form Builder – IvyForms 0.3.1, at frontend/src/views/public/fields/EmailFormField.vue

93 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <template>
2 <div
3 :class="[
4 'ivyforms-field',
5 'ivyforms-field__email',
6 'ivyforms-field__email_' + field.id,
7 field.cssClasses,
8 ]"
9 >
10 <IvyFormItem
11 :label="field.hideLabel ? '' : field.label"
12 :required="field.required"
13 :error="error"
14 :prop="field.type + '_' + field.fieldIndex"
15 :show-info="!!field.description && !error"
16 :info-text="field.description || ''"
17 >
18 <IvyTextInput
19 :id="fieldID"
20 v-model="localModelValue"
21 class="ivyforms-field__email-input"
22 type="email"
23 :placeholder="field.placeholder"
24 :disabled="disabled"
25 :readonly="field.readOnly"
26 :required="field.required"
27 />
28 </IvyFormItem>
29 </div>
30 </template>
31
32 <script setup lang="ts">
33 import { computed, inject } from 'vue'
34
35 interface Field {
36 id: number
37 formId: number
38 fieldIndex: number
39 type: string
40 label: string
41 placeholder?: string
42 required?: boolean
43 hideLabel?: boolean
44 readOnly?: boolean
45 description?: string
46 cssClasses?: string
47 // Any other field properties from your data
48 }
49
50 interface FieldProps {
51 modelValue: string | number | null | undefined
52 field: Field
53 disabled?: boolean
54 error?: string
55 }
56
57 const props = withDefaults(defineProps<FieldProps>(), {
58 modelValue: '',
59 disabled: false,
60 error: '',
61 })
62
63 const emit = defineEmits(['update:modelValue'])
64
65 // Inject clearFieldError function from parent
66 const clearFieldError = inject<(fieldKey: string) => void>('clearFieldError', () => {})
67
68 // Generate field key for clearing errors
69 const fieldKey = computed(() => {
70 return props.field.type + '_' + props.field.fieldIndex
71 })
72
73 // Handle input event to clear errors when user starts typing
74 const handleInput = (value: string | number | null | undefined) => {
75 emit('update:modelValue', value)
76 clearFieldError(fieldKey.value)
77 }
78
79 const localModelValue = computed({
80 get() {
81 return props.modelValue
82 },
83 set(value) {
84 handleInput(value)
85 },
86 })
87
88 // Generate unique field ID as a string
89 const fieldID = computed(() => {
90 return `ivyforms-field__email-input_${props.field.formId || ''}_${props.field.fieldIndex || ''}`
91 })
92 </script>
93