vendredi 25 décembre 2015

Passing PHP Variable from GET to current form if isset laravel 5

Ok, I've searched the last couple of days and haven't been able to find an answer that made sense. I'm positive it's doable but not sure if I'm in over my head. I'm new to Laravel 5 and also pretty new to PHP. I'm trying to send a inputted string from the GET['quote'] part of my (laravel collective) form to the same form that is updated with a new view below it, that utilizes the GET variable. Basically keeping whatever someone types in the searchbox after refresh.

Normally I would just echo out the needed variable if it's "set" then leave it empty if it isn't in the 'value' = "" section of the textbox. In Laravel with this form I'm not able to do that due to the rendering of the child view in the parent view(parent first, then child), if I understand correctly. Is there any work around? I'm about ready to just do the old echo within the form if I can't find a solution.

Thanks in advance! This site has helped me with a lot of my questions over the last few months.

Current Form on a Parent View.

{{ Form::open(array('url' => 'search', 'method' => 'get')) }}
{!! Form::text('query', '', [
                    'class' => "form-table",
                    'placeholder' => "Search Keywords",
                    'value' => "{{ $query }}"
                    ]) !!}</td>
{!! Form::submit('Submit') !!}
{{  Form::close() }}

Code below form is to pass the textbox string to another view and show it below this form. I don't know any JS so I'm kind of fumbling about here probably trying to make something work that just wont work.

@yield('child')

Code below here is from my controller.

public function getSearch(){
$title = "Page Title";
$query = "some string"; //This was set to $_GET['query'] but was failing.
return view('pages.search')->with("title", $title)->with("query", $query);



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire