extjac said:
Have you tried using javascript?
hi Extjac Thank for you comment
but i just want to push my data itself, it mean category table (it has parent) to combobox for display, i dont think i need to use javascript for this?
kencytbb said:
My category name is testzzz and parent category of testzzz is events but it nonfather category is selected
<select name="catfather"> @foreach($catefather as $cf) @if($cate->parents->idcategory != $cf->idcategory) <option value="{{$cf->idcategory}}}" selected>{{{$cf->cat_name}}}</option> @else <option selected disabled hidden value=''></option>" <option value="{{$cf->idcategory}}}">{{{$cf->cat_name}}}</option> @endif @endforeach </select>
Excuse me, but your if statement seems wrong to me.
If the parent id ($cate->parents) equals the id of the category in the foreach ($cf) then it sould be selected. Otherwise not. You are doing the opposite. Replace != with ==.
You don't need the option which is disabled inside the else, you need it right before the foreach.
I strongly racommend you to change the name of the select from "catfather" to "cat_father". In your edit view, laravel will automaticlly recognize the temporary value and set it as selected.
Hello,
I did same thing for one of my project, and Its better to utilize the power of relationships and scopes in eloquent. I had a nice structured model in my case, but here is modified version from that model for you.
Hope that helps you!
Firtzberg said:
kencytbb said:
My category name is testzzz and parent category of testzzz is events but it nonfather category is selected
<select name="catfather"> @foreach($catefather as $cf) @if($cate->parents->idcategory != $cf->idcategory) <option value="{{$cf->idcategory}}}" selected>{{{$cf->cat_name}}}</option> @else <option selected disabled hidden value=''></option>" <option value="{{$cf->idcategory}}}">{{{$cf->cat_name}}}</option> @endif @endforeach </select>
Excuse me, but your if statement seems wrong to me.
If the parent id ($cate->parents) equals the id of the category in the foreach ($cf) then it sould be selected. Otherwise not. You are doing the opposite. Replace != with ==.
You don't need the option which is disabled inside the else, you need it right before the foreach.
I strongly racommend you to change the name of the select from "catfather" to "cat_father". In your edit view, laravel will automaticlly recognize the temporary value and set it as selected.>dakshhmehta said:Hello,
I did same thing for one of my project, and Its better to utilize the power of relationships and scopes in eloquent. I had a nice structured model in my case, but here is modified version from that model for you.
Hope that helps you!
thank you very much i did it, it work well :P
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community