Fixed link type always defaulting to link when editing

This commit is contained in:
Julian Prieber 2022-11-10 19:03:35 +01:00
parent b9922a36b6
commit 759e859102
2 changed files with 6 additions and 3 deletions

View File

@ -121,14 +121,15 @@ class UserController extends Controller
$data['LinkTypes'] = LinkType::get(); $data['LinkTypes'] = LinkType::get();
$data['LinkData'] = $linkData; $data['LinkData'] = $linkData;
$data['LinkID'] = $id; $data['LinkID'] = $id;
$data['title'] = "link";
$data['linkTypeID'] = "1"; $data['linkTypeID'] = "1";
$data['title'] = "Custom Link";
if (Route::currentRouteName() != 'showButtons') { if (Route::currentRouteName() != 'showButtons') {
$links = DB::table('links')->where('id', $id)->first(); $links = DB::table('links')->where('id', $id)->first();
$bid = $links->button_id; $bid = $links->button_id;
if($bid == 1 or $bid == 2){ if($bid == 1 or $bid == 2){
$data['linkTypeID'] = "1"; $data['linkTypeID'] = "1";
} elseif ($bid == 42) { } elseif ($bid == 42) {
@ -138,6 +139,8 @@ class UserController extends Controller
} else { } else {
$data['linkTypeID'] = "2"; $data['linkTypeID'] = "2";
} }
$data['title'] = LinkType::where('id', $data['linkTypeID'])->value('title');
} }
foreach ($data['LinkTypes']->toArray() as $key => $val) { foreach ($data['LinkTypes']->toArray() as $key => $val) {

View File

@ -15,7 +15,7 @@
<div class="form-group col-lg-8 flex justify-around"> <div class="form-group col-lg-8 flex justify-around">
<label class='font-weight-bold'>Link Type: </label> <label class='font-weight-bold'>Link Type: </label>
<div class="btn-group shadow m-2"> <div class="btn-group shadow m-2">
<button type="button" id='btnLinkType' class="border-0 p-1" title='Click to change link type' data-toggle="modal" data-target="#SelectLinkType">link</button> <button type="button" id='btnLinkType' class="border-0 p-1" title='Click to change link type' data-toggle="modal" data-target="#SelectLinkType">{{$title}}</button>