0

So i have an Table called 'FAQ' in here I have (question, answer, folder_id). for the question and answer i want to use CKeditor5. i can see the CKeditor clearly and the fonts etc are useable. but when i want to post the data to my controller I get this message back: enter image description here

even though i filled these fields in, any idea how to resolve this error?

Create.blade

 <form method="post" action="{{ route('admin.faq.store') }}" enctype="multipart/form-data">
        @csrf
        <div name="question">
            <label for="question">{{('question')}}</label>
            <div class="form-group" id="editorClassic" >
                <input type="text" class="form-control" >
            </div>
        </div>
        <br />
        <div>
            <label for="answer">{{('answer')}}</label>
            <div class="form-group" id="editor">
                <input type="text" class="form-control" name="answer" />
            </div>
        </div>
        <br />
        <div class="form-group">
            <label for="folder_id">{{('folder')}}</label>
            <select name="faqsfolder_id">
                @foreach($faqsfolder as $faqsfolder)
                <option value="{{$faqsfolder->id}}">{{$faqsfolder->name}}</option>
                @endforeach
            </select>

        </div>
        <button type="submit" class="btn btn-primary">Add FAQ</button>
    </form>

store function (not finished i know)

 public function store(Request $request)
    {
        $request->validate([
            'question' => 'required',
            'answer' => 'required',
            'faqsfolder_id' => [
                'required', 'exists:folder,id'
            ],
        ]);
13
  • Can you verify what data is in your request? Commented Nov 1, 2022 at 8:10
  • i dont think i can, i tried to put a DD under the $request->validate, but it still returns "The question field is required" etc. Commented Nov 1, 2022 at 8:20
  • You should be able to see in the webbrowser what you are sending to the server. If you use chrome devtools->network->all->select request->(on right side) select payload Commented Nov 1, 2022 at 8:23
  • imgur.com/a/LP8C3n9 Commented Nov 1, 2022 at 8:24
  • imgur.com/a/e60F0NW Commented Nov 1, 2022 at 8:27

1 Answer 1

1

You are missing a name attribute for your input <input type="text" class="form-control" >

If you change it into <input type="text" class="form-control" name="question"> then your variable should be sent to the server :D

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.