mercredi 6 janvier 2016

Option tag not displaying default selected choice in laravel 5.1 using select2

I have been facing a strange problem in select2.The default selected option I want to display is not happening.If the cursor is placed on the select2 box in question,it displays the required value as an 'alt' attribute in image.So the thing is that the value is passed to the select2 box but it isnt displayed!Here's my code:

<div class="row">
                    <?php 
                            $country = explode('_', $patron_address['country']);
                            $countryId = $country[0];
                            $countryCode = $country[1];
                            $countryName = $country[2];

                    ?>
                    <div class='col-md-6'>
                            <div class="form-group{!! ($errors->has('country'))? ' has-error':'' !!}">
                                <label for="country" class="control-label col-md-3">
                                    Country
                                    <span class="required" aria-required="true">*</span>
                                </label>
                                <div class="col-md-8">
                                     <select name="country" id="select2_country" class="form-control">
                                        <option></option>
                                     @if($country)
                                     <option value="{!! $countryName !!}" selected="selected">{!! $countryName !!}</option>
                                     @endIf
                                     </select>
                                    @if ($errors->has('country'))
                                        <span class="help-block">{!! $errors->first('country') !!}</span>
                                    @endif
                                </div>
                            </div>`enter code here`
                        </div>
                      </div>

Even if instead of {!! $countryName !!},if I use any hard coded option to be displayed,same problem persists. It's been done in laravel 5.1. Any suggestions?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire