Check that the fieldset exists before trying to detach it from the fieldset
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
eedc14401a
commit
7794c2f44b
1 changed files with 12 additions and 5 deletions
|
@ -133,12 +133,19 @@ class CustomFieldsController extends Controller
|
||||||
|
|
||||||
$this->authorize('update', $field);
|
$this->authorize('update', $field);
|
||||||
|
|
||||||
|
// Check that the field exists - this is mostly related to the demo, where we
|
||||||
|
// rewrite the data every x minutes, so it's possible someone might be disassociating
|
||||||
|
// a field from a fieldset just as we're wiping the database
|
||||||
|
if (($field) && ($fieldset_id)) {
|
||||||
|
|
||||||
if ($field->fieldset()->detach($fieldset_id)) {
|
if ($field->fieldset()->detach($fieldset_id)) {
|
||||||
return redirect()->route('fieldsets.show', ['fieldset' => $fieldset_id])
|
return redirect()->route('fieldsets.show', ['fieldset' => $fieldset_id])
|
||||||
->with("success", trans('admin/custom_fields/message.field.delete.success'));
|
->with("success", trans('admin/custom_fields/message.field.delete.success'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->back()->withErrors(['message' => "Field is in-use"]);
|
}
|
||||||
|
|
||||||
|
return redirect()->back()->withErrors(['message' => "Error deleting field from fieldset"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue