mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Small fix for reordering fields
Fixes Illuminate\Database\QueryException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'order' cannot be null (SQL: insert into `custom_field_custom_fieldset` (`custom_field_id`, `custom_fieldset_id`, `order`, `required`) values (12, 7, , 0)) [ch1151] This needs revisiting for a more solid fix, especially for data that was already entered bad.
This commit is contained in:
parent
9995f1a743
commit
b6d2392303
|
@ -172,7 +172,7 @@ class CustomFieldsetsController extends Controller
|
||||||
* @since [v1.8]
|
* @since [v1.8]
|
||||||
* @return View
|
* @return View
|
||||||
*/
|
*/
|
||||||
public function associate($id)
|
public function associate(Request $request, $id)
|
||||||
{
|
{
|
||||||
|
|
||||||
$set = CustomFieldset::find($id);
|
$set = CustomFieldset::find($id);
|
||||||
|
@ -180,12 +180,12 @@ class CustomFieldsetsController extends Controller
|
||||||
$this->authorize('update', $set);
|
$this->authorize('update', $set);
|
||||||
|
|
||||||
foreach ($set->fields as $field) {
|
foreach ($set->fields as $field) {
|
||||||
if ($field->id == Input::get('field_id')) {
|
if ($field->id == $request->input('field_id')) {
|
||||||
return redirect()->route("fieldsets.show", [$id])->withInput()->withErrors(['field_id' => trans('admin/custom_fields/message.field.already_added')]);
|
return redirect()->route("fieldsets.show", [$id])->withInput()->withErrors(['field_id' => trans('admin/custom_fields/message.field.already_added')]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$results=$set->fields()->attach(Input::get('field_id'), ["required" => (Input::get('required') == "on"),"order" => Input::get('order')]);
|
$results = $set->fields()->attach(Input::get('field_id'), ["required" => ($request->input('required') == "on"),"order" => $request->input('order', 1)]);
|
||||||
|
|
||||||
return redirect()->route("fieldsets.show", [$id])->with("success", trans('admin/custom_fields/message.field.create.assoc_success'));
|
return redirect()->route("fieldsets.show", [$id])->with("success", trans('admin/custom_fields/message.field.create.assoc_success'));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue