Tab Betriebsmittel: change type of field Kaution to number, add validation if numeric

This commit is contained in:
ma0068
2025-06-16 16:01:41 +02:00
parent 5140d9de31
commit cb2ed4696c
2 changed files with 17 additions and 1 deletions
@@ -158,6 +158,11 @@ class BetriebsmittelP extends FHCAPI_Controller
], [
'uid_in_person' => $this->p->t('person', 'error_uidNotInPerson')
]);
$this->form_validation->set_rules('kaution', 'Kaution', 'numeric', [
'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Kaution'])
]);
$this->validateNewOrUpdate();
$betriebsmitteltyp = $this->input->post('betriebsmitteltyp');
@@ -241,6 +246,10 @@ class BetriebsmittelP extends FHCAPI_Controller
public function updateBetriebsmittel($betriebsmittelperson_id)
{
$this->form_validation->set_rules('kaution', 'Kaution', 'numeric', [
'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Kaution'])
]);
$this->validateNewOrUpdate();
$betriebsmitteltyp = $this->input->post('betriebsmitteltyp');
@@ -292,6 +292,12 @@ export default {
this.formData.anmerkung = null;
this.formData.beschreibung = null;
this.statusNew = true;
},
//helper function: workaround to trigger validation if input is not a number
normalizeKaution() {
if (this.formData.kaution === null || this.formData.kaution === '') {
this.formData.kaution = 'xxx'
}
}
},
created() {
@@ -401,9 +407,10 @@ export default {
<div class="row mb-3">
<form-input
type="text"
type="number"
:label="$p.t('infocenter/kaution')"
name="kaution"
@blur="normalizeKaution"
v-model="formData.kaution"
>
</form-input>