mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-09 00:42:36 +00:00
Add forms
demo page
This commit is contained in:
parent
9f8003ad9d
commit
4929f978f2
24 changed files with 3002 additions and 22 deletions
54
apps/showcase/doc/forms/dynamic/DynamicFormMessage.vue
Normal file
54
apps/showcase/doc/forms/dynamic/DynamicFormMessage.vue
Normal file
|
@ -0,0 +1,54 @@
|
|||
<template>
|
||||
<Message v-if="visible" :severity>
|
||||
<slot>{{ message }}</slot>
|
||||
</Message>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { isNotEmpty } from '@primeuix/utils';
|
||||
|
||||
export default {
|
||||
name: 'DynamicFormLabel',
|
||||
props: {
|
||||
errorType: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
severity: {
|
||||
type: String,
|
||||
default: 'error'
|
||||
}
|
||||
},
|
||||
inject: {
|
||||
$pcForm: {
|
||||
default: undefined
|
||||
},
|
||||
$fcDynamicFormField: {
|
||||
default: undefined
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
visible() {
|
||||
return this.invalid && (this.error || this.errorType === undefined);
|
||||
},
|
||||
message() {
|
||||
return this.errorType ? this.error?.message : this.errors?.[0]?.message;
|
||||
},
|
||||
error() {
|
||||
return this.errors?.find((error) => error.errorType === this.errorType || isNotEmpty(error[this.errorType]));
|
||||
},
|
||||
fieldName() {
|
||||
return this.$fcDynamicFormField?.$props.name;
|
||||
},
|
||||
state() {
|
||||
return this.$pcForm?.states?.[this.fieldName];
|
||||
},
|
||||
errors() {
|
||||
return this.state?.errors;
|
||||
},
|
||||
invalid() {
|
||||
return this.state?.invalid;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue