Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
First of all, hello, and forgive me in a slightly worse English language


I want to, for example, if I come with http://nesto.test/admin/post?main_title=post, automatically select value is 'post', and if I come with http://nesto.test/admin/post?main_title=manifestacion , automatically select value will be 'manifestation'

I hope you understand what I want, thank you in advance

What I have tried:

index.blade.php


<div class="col-sm-6 col-xs-12">
                <div class="toolbar-tools pull-right">
                    <ul class="nav navbar-right">
                        @if(Entrust::can('add_post'))
                            <li>
                                @foreach($main_title_options as $option)
                                    <a href="{{ url('admin/post/create/' . $_GET['main_title']) }}" @if(isset($_GET['main_title']) && $_GET['main_title'] == $option->value)>

                                        class="fa fa-plus">
                                        {{ trans('labels.create_' . $option->value   ) }}
                                        @else
                                            {{ trans('labels.create_posts') }}
                                        @endif
                                        @endforeach

                                    </a>
                            </li>
                        @endif
                    </ul>
                </div>
            </div>



main_title.blade.php:

<div class="form-group">
                     <label for="main_title">{{ trans('labels.main_title') }}</label>
                     <select v-model="post.main_title | mainTitle" name="main_title"
                             id="main_title"
                             class="form-control">
                         @foreach($main_title_options as $option)
                             <option {{ $main_title == $option->value ? 'selected="selected"' : '' }} value="{{ $option->value }}">
                                 {{ trans('labels.'.$option->value) }}
                             </option>
                         @endforeach
                     </select>
                 </div>
Posted
Updated 16-Oct-18 2:00am
v3

1 solution

It seems you are using laravel pass your parameter to controller and then from controller pass value to view.
1. To Send GET params from controller to blade
public function youcontroller(Request $param)
{
    //Put main_title in a variable
    $main_title = $param->main_title;
     //  set main_title_options and your other code 
    //Pass main_title to view
    return view('bladeView', compact('main_title' , 'main_title_options' ));
}
2. Then in your view( .blade) check if you are getting proper values and do.
{{ ($main_title == $option->value) ? 'selected' : '' }}
 
Share this answer
 
v3
Comments
Member 13962120 16-Oct-18 8:01am    
It did not work, but thanks for the effort, i updated question

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900