Made link title optional

Made link title (previously required) optional when adding personal LittleLink links on the User/Admin Panel.
If the 'Title' field is left empty, the button name is now used instead of rejecting the addition.
This commit is contained in:
Julian Prieber 2022-03-18 12:04:13 +01:00
parent fe7fc9f714
commit 7fb6068d49
2 changed files with 13 additions and 4 deletions

View File

@ -60,11 +60,14 @@ class UserController extends Controller
{
$request->validate([
'link' => 'required',
'title' => 'required',
'title' => '',
'button' => 'required'
]);
$link = $request->link;
if ($request->title == '')
$title = $request->button;
else
$title = $request->title;
$button = $request->button;

View File

@ -7,20 +7,26 @@
<form action="{{ route('addLink') }}" method="post">
@csrf
<div class="form-group col-lg-8">
<label>Link</label>
<label>Link*</label>
<input type="text" name="link" class="form-control" placeholder="https://google.com">
</div>
<div class="form-group col-lg-8">
<label>Title</label>
<input type="text" name="title" class="form-control" placeholder="Google">
<input type="text" name="title" class="form-control" placeholder="Internal name (optional)">
</div>
<div class="form-group col-lg-8">
<label for="exampleFormControlSelect1">Button</label>
<label for="exampleFormControlSelect1">Button*</label>
<select class="form-control" name="button">
@foreach($buttons as $button)
@if($button->name == 'custom')
<option>Custom button (Title determines text on button)</option>
@else
<option> {{ $button->name }} </option>
@endif
@endforeach
</select>
<br>
<label>* Required fields</label><br>
</div>
<button type="submit" class="mt-3 ml-3 btn btn-info">Submit</button>
</form>