added a way to manipulate validator attribute names

This commit is contained in:
spencerrlongg 2024-09-30 20:09:00 -05:00
parent cd3059f790
commit 4f9f035c69
2 changed files with 6 additions and 2 deletions

View file

@ -483,7 +483,12 @@ class AssetModelsController extends Controller
$rules[$field] = $validation;
}
$validator = Validator::make($data, $rules);
$attributes = [];
foreach ($model->fieldset->fields as $field) {
$attributes[$field->db_column] = trim(preg_replace('/_+|snipeit|\d+/', ' ', $field->db_column));
}
$validator = Validator::make($data, $rules)->setAttributeNames($attributes);
if($validator->fails()){
$this->validatorErrors = $validator->errors();

View file

@ -127,7 +127,6 @@
<?php
$errormessage = $errors->first($field->db_column_name());
if ($errormessage) {
$errormessage = preg_replace('/snipeit|\d+/', '', $errormessage);
print('<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> '.$errormessage.'</span>');
}
?>