Skip to content

A free open source IT asset/license management system

Fixes format property on invalid custom field object

snipe884b6b0270d9
diff --git a/app/Http/Controllers/CustomFieldsController.php b/app/Http/Controllers/CustomFieldsController.php
index 04819a9b0f..68e78b14c6 100644
--- a/app/Http/Controllers/CustomFieldsController.php
+++ b/app/Http/Controllers/CustomFieldsController.php
@@ -178,20 +178,25 @@ class CustomFieldsController extends Controller
*/
public function edit($id)
{
- $field = CustomField::find($id);
+ if ($field = CustomField::find($id)) {
- $this->authorize('update', $field);
+ $this->authorize('update', $field);
- $customFormat = '';
- if((stripos($field->format, 'regex') === 0) && ($field->format !== CustomField::PREDEFINED_FORMATS['MAC'])) {
- $customFormat = $field->format;
- }
+ $customFormat = '';
+ if((stripos($field->format, 'regex') === 0) && ($field->format !== CustomField::PREDEFINED_FORMATS['MAC'])) {
+ $customFormat = $field->format;
+ }
- return view("custom_fields.fields.edit",[
- 'field' => $field,
- 'customFormat' => $customFormat,
- 'predefinedFormats' => Helper::predefined_formats()
- ]);
+ return view("custom_fields.fields.edit",[
+ 'field' => $field,
+ 'customFormat' => $customFormat,
+ 'predefinedFormats' => Helper::predefined_formats()
+ ]);
+ }
+
+ return redirect()->route("fields.index")
+ ->with("error", trans('admin/custom_fields/message.field.invalid'));
+
}