Merge branch 'develop' of https://github.com/snipe/snipe-it into develop

This commit is contained in:
snipe 2021-04-20 14:49:38 -07:00
commit 3138f45e8c
3 changed files with 12 additions and 5 deletions

View file

@ -95,7 +95,14 @@ class CustomFieldsController extends Controller
$field = new CustomField;
$data = $request->all();
$validator = Validator::make($data, $field->validationRules());
$regex_format = null;
if (str_contains($data["format"], "regex:")){
$regex_format = $data["format"];
}
$validator = Validator::make($data, $field->validationRules($regex_format));
if ($validator->fails()) {
return response()->json(Helper::formatStandardApiResponse('error', null, $validator->errors()));
}

View file

@ -353,7 +353,7 @@ class CustomField extends Model
* @since [v4.1.10]
* @return array
*/
public function validationRules()
public function validationRules($regex_format = null)
{
return [
"name" => "required|unique:custom_fields",
@ -362,7 +362,7 @@ class CustomField extends Model
Rule::in(['text', 'listbox', 'textarea', 'checkbox', 'radio'])
],
'format' => [
Rule::in(array_merge(array_keys(CustomField::PREDEFINED_FORMATS), CustomField::PREDEFINED_FORMATS))
Rule::in(array_merge(array_keys(CustomField::PREDEFINED_FORMATS), CustomField::PREDEFINED_FORMATS, [$regex_format]))
],
'field_encrypted' => "nullable|boolean"
];

View file

@ -160,10 +160,10 @@
<a href="{{ route('locations.edit', ['location' => $location->id]) }}" style="width: 50%;" class="btn btn-sm btn-primary pull-left">{{ trans('admin/locations/table.update') }} </a>
</div>
<div class="col-md-12" style="padding-top: 5px;">
<a href="{{ route('locations.print_assigned', ['location' => $location->id]) }}" style="width: 50%;" class="btn btn-sm btn-default pull-left">{{ trans('admin/locations/table.print_assigned') }} </a>
<a href="{{ route('locations.print_assigned', ['locationId' => $location->id]) }}" style="width: 50%;" class="btn btn-sm btn-default pull-left">{{ trans('admin/locations/table.print_assigned') }} </a>
</div>
<div class="col-md-12" style="padding-top: 5px;">
<a href="{{ route('locations.print_all_assigned', ['location' => $location->id]) }}" style="width: 50%;" class="btn btn-sm btn-default pull-left">{{ trans('admin/locations/table.print_all_assigned') }} </a>
<a href="{{ route('locations.print_all_assigned', ['locationId' => $location->id]) }}" style="width: 50%;" class="btn btn-sm btn-default pull-left">{{ trans('admin/locations/table.print_all_assigned') }} </a>
</div>
</div>