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 / ParagraphFormField.vue

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

91 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__textarea',
6 'ivyforms-field__textarea_' + 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__textarea-input"
22 type="textarea"
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 interface FieldProps {
50 modelValue: string | number | null | undefined
51 field: Field
52 disabled?: boolean
53 error?: string
54 }
55
56 const props = withDefaults(defineProps<FieldProps>(), {
57 modelValue: '',
58 disabled: false,
59 error: '',
60 })
61
62 const emit = defineEmits(['update:modelValue'])
63
64 // Inject clearFieldError function from parent
65 const clearFieldError = inject<(fieldKey: string) => void>('clearFieldError', () => {})
66
67 // Generate field key for clearing errors
68 const fieldKey = computed(() => {
69 return props.field.type + '_' + props.field.fieldIndex
70 })
71
72 // Handle input event to clear errors when user starts typing
73 const handleInput = (value: string | number | null | undefined) => {
74 emit('update:modelValue', value)
75 clearFieldError(fieldKey.value)
76 }
77
78 const localModelValue = computed({
79 get() {
80 return props.modelValue
81 },
82 set(value) {
83 handleInput(value)
84 },
85 })
86 // Generate unique field ID as a string
87 const fieldID = computed(() => {
88 return `ivyforms-field__paragraph-input_${props.field.formId || ''}_${props.field.fieldIndex || ''}`
89 })
90 </script>
91