Skip to content

Commit

Permalink
Merge pull request #10480 from snipe/fixes/check_for_valid_custom_field
Browse files Browse the repository at this point in the history
Fixed format property on invalid custom field object when trying to edit a field that doesn't exist
  • Loading branch information
snipe committed Jan 4, 2022
2 parents 7a1ab12 + 884b6b0 commit b78e610
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions app/Http/Controllers/CustomFieldsController.php
Expand Up @@ -178,20 +178,25 @@ public function destroy($field_id)
*/
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'));

}


Expand Down

0 comments on commit b78e610

Please sign in to comment.