Form error message
This commit is contained in:
@@ -24,6 +24,7 @@ import CardContent from './ui/card/CardContent.vue';
|
|||||||
import CardHeader from './ui/card/CardHeader.vue';
|
import CardHeader from './ui/card/CardHeader.vue';
|
||||||
import CardTitle from './ui/card/CardTitle.vue';
|
import CardTitle from './ui/card/CardTitle.vue';
|
||||||
import Input from './ui/input/Input.vue';
|
import Input from './ui/input/Input.vue';
|
||||||
|
import FormError from './ui/form/FormError.vue';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
type: PerceptronType;
|
type: PerceptronType;
|
||||||
@@ -52,7 +53,7 @@ const maxIterationsInput = ref<{
|
|||||||
} | null>(null);
|
} | null>(null);
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
type: props.type,
|
type: props.type,
|
||||||
dataset: '',
|
dataset: selectedDatasetCopy.value,
|
||||||
weight_init_method: selectedMethod.value,
|
weight_init_method: selectedMethod.value,
|
||||||
hidden_layers: hiddenLayers.value,
|
hidden_layers: hiddenLayers.value,
|
||||||
hidden_layers_neurons: hiddenLayersNeurons.value,
|
hidden_layers_neurons: hiddenLayersNeurons.value,
|
||||||
@@ -95,6 +96,8 @@ watch(maxIterations, (value) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
watch(selectedDatasetCopy, (newvalue) => {
|
watch(selectedDatasetCopy, (newvalue) => {
|
||||||
|
form.clearErrors('dataset');
|
||||||
|
|
||||||
const selectedDatasetCopy = props.datasets.find(
|
const selectedDatasetCopy = props.datasets.find(
|
||||||
(dataset) => dataset.label === newvalue
|
(dataset) => dataset.label === newvalue
|
||||||
) || null;
|
) || null;
|
||||||
@@ -129,7 +132,11 @@ const trainingId = ref<string>('');
|
|||||||
|
|
||||||
function startTraining() {
|
function startTraining() {
|
||||||
if (!selectedDatasetCopy.value) {
|
if (!selectedDatasetCopy.value) {
|
||||||
alert('Veuillez sélectionner un dataset avant de lancer l\'entraînement.');
|
form.setError(
|
||||||
|
'dataset',
|
||||||
|
'Un dataset est nécessaire avant de lancer l\'entraînement.',
|
||||||
|
);
|
||||||
|
console.log(form.errors);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +206,7 @@ watch(selectedDatasetCopy, (newValue) => {
|
|||||||
</NativeSelectOption>
|
</NativeSelectOption>
|
||||||
</NativeSelect>
|
</NativeSelect>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<div v-if="props.errors?.selectedDatasetCopy">{{ props.errors?.selectedDatasetCopy }}</div>
|
<FormError :error="form.errors.dataset || props.errors?.selectedDatasetCopy" />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
error?: string
|
||||||
|
}>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="text-sm text-red-500">{{ props.error }}</div>
|
||||||
|
</template>
|
||||||
Reference in New Issue
Block a user