V
V
Vitaly2018-03-20 15:28:21
JavaScript
Vitaly, 2018-03-20 15:28:21

Loading values ​​into laravel form fields?

Good afternoon. I ran into this problem, maybe someone can help me to solve it.
I have a form with 3 fields

<input type="text" name="title" id="title">
<input type="text" name="desc" id="desc">
<select name="type" id="select_type">
<option value="1">Type 1</option>
<option value="2">Type 2</option>
</select>


The task is to load values ​​from the database into the title and desc fields when selecting a specific value from select.
I understand that this should be an ajax request, but not when I didn’t come across such a thing, how to implement a class that will process an ajax request that will eventually return data to me.

Controller
public function create()
    {

        $quote_types = \App\QuoteType::get()->pluck('title', 'id')->prepend(trans('global.app_please_select'), '');
        $quote_section = \App\QuoteSectionType::get()->pluck('title', 'id')->prepend(trans('global.app_please_select'), '');
        $attchments = \App\QuoteAttachment::get()->pluck('title', 'id');
        $created_bies = \App\User::get()->pluck('name', 'id')->prepend(trans('global.app_please_select'), '');


        return view('admin.quotes.create', compact('quote_types', 'attchments', 'created_bies', 'quote_section'));
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question