Form error message
linter / quality (push) Successful in 4m19s
tests / ci (8.4) (push) Successful in 5m21s
tests / ci (8.5) (push) Successful in 4m34s

This commit is contained in:
2026-09-16 19:27:27 +02:00
parent 6d4fdffee9
commit 9086364db7
2 changed files with 20 additions and 3 deletions
+10 -3
View File
@@ -24,6 +24,7 @@ import CardContent from './ui/card/CardContent.vue';
import CardHeader from './ui/card/CardHeader.vue';
import CardTitle from './ui/card/CardTitle.vue';
import Input from './ui/input/Input.vue';
import FormError from './ui/form/FormError.vue';
const props = defineProps<{
type: PerceptronType;
@@ -52,7 +53,7 @@ const maxIterationsInput = ref<{
} | null>(null);
const form = useForm({
type: props.type,
dataset: '',
dataset: selectedDatasetCopy.value,
weight_init_method: selectedMethod.value,
hidden_layers: hiddenLayers.value,
hidden_layers_neurons: hiddenLayersNeurons.value,
@@ -95,6 +96,8 @@ watch(maxIterations, (value) => {
});
watch(selectedDatasetCopy, (newvalue) => {
form.clearErrors('dataset');
const selectedDatasetCopy = props.datasets.find(
(dataset) => dataset.label === newvalue
) || null;
@@ -129,7 +132,11 @@ const trainingId = ref<string>('');
function startTraining() {
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;
}
@@ -199,7 +206,7 @@ watch(selectedDatasetCopy, (newValue) => {
</NativeSelectOption>
</NativeSelect>
</FormControl>
<div v-if="props.errors?.selectedDatasetCopy">{{ props.errors?.selectedDatasetCopy }}</div>
<FormError :error="form.errors.dataset || props.errors?.selectedDatasetCopy" />
</FormItem>
</FormField>