1

I have a required artwork-title label and input field and I have been wondering what's the best way to add the required * symbol. I can just create an inline element, go through my entire project and add it to every required input, however, I assume there's a cleaner way for doing this and that's why I'm reaching to you people.

HTML form:

<form class='uploadForm' action="{{ route('uploadArtwork') }}" method="POST" enctype="multipart/form-data">

    <div class="form-group">
        <label class='label' for="artwork-title">Title</label>
        <input class='input' type="text" name="artwork-title" placeholder="Title" value='{{ Request::old('artwork-title') }}'>
        @include('partials.invalid', ['field' => 'artwork-title'])
    </div>

    <div class="form-group">
        <input type="file" name='files[]' multiple>
        @include('partials.invalid', ['field' => 'files'])
    </div>

    {{ csrf_field() }}
    <button class='Submit' type="submit" name="submit">Publish</button>

</form>

Back-end validation:

$this->validate($request, [
    'artwork-title' => 'required|max:120',
    'files' => 'required'
]);
Onyx
  • 5,186
  • 8
  • 39
  • 86
  • You are probably looking for this answer https://stackoverflow.com/questions/11197671/use-css-to-automatically-add-required-field-asterisk-to-form-inputs – alariva Aug 03 '18 at 02:33

0 Answers0