0

Getting error on populating select list

 <select name="notificationtype" required class="form-control">
         <option value="sms" {{isset($template->type) ? @if($template->type=='sms' "selected=true" @endif : 'sms'}}> {{ 'SMS'}}</option>
    <option value="email" {{ isset($template->type) ? @if($template->type=='email' "selected=true" @endif : 'email'}}>{{'Email'}}</option> </select>
1

1 Answer 1

1

The problem is in this line :

{{isset($template->type) ? @if($template->type=='sms' "selected=true" @endif : 'sms'

try it like this :

<select name="notificationtype" required class="form-control">
    <option value="sms" @if(isset($template->type) && $template->type=='sms') "selected=true" @endif > SMS </option>
    <option value="email" @if(isset($template->type) && $template->type=='email') "selected=true" @endif > Email </option> 
</select>
Sign up to request clarification or add additional context in comments.

6 Comments

While the error get resolved but selection is still not working and only first item is being selected
try it replacing "selected=true" with "selected" !!
So you didn't have the type seted in $template->type !!
Is this type keyword issue in blade template?
I think it's just a type value !! is it equal exactly to 'sms' including case sensitive ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.