Q
Q
qu1kgg2020-03-01 12:59:13
Laravel
qu1kgg, 2020-03-01 12:59:13

How to pass another View with return?

Good afternoon, such a question as in Laravel with return response()->json($data); pass
View::make('form')->with('param', '1');
just enter $view = View::make('form')->with('param', '1');does not pass

More:
there is form.blade.php there is an input with connected typeahead.js when entering it sends a request to the controller and then receives data (return response()->json ($data);), but I also need to pass the $form variable from the controller in form.blade.php

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
yevhenkoriakin, 2020-03-01
@yevhenkoriakin

Good afternoon!
I can not understand the question, but I will write.
You have a controller, it has a method that returns you a form
for example

public function index()
    {
        return view('home');
    }

 If you need to submit something along with the form
return view('home', ['form' => 'value', 'key' => 'value2']);

https://laravel.com/docs/6.x/views#passing-data-to...
for typeahead
make a new method in the controller that will return json
For this method make a new route and specify the same route as the data source for typeahead script.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question