How to indent option in select or put hyphens before each sub categories option in select box on the basis of depth

烂漫一生 提交于 2019-12-11 18:29:00

问题


I want to one indent of put hyphens before each sub categories option in select box. Basically i have generated select box using blade recursion and the select box generation properly, But the issue with the option is sub category option not indenting or i am not able to put indent/hyphens before options.

Blade page

@if (count($configList) > 0)
    <select name="category">
       <option value="0">Select a Category</option>
        @include('admin.configuration.selectoption', $configList)
     </select>
@endif

Recursive blade page to generate options

Recursive blade page

 @foreach($configList as $item)
    @if(isset($category))
        @if($category[0]->parentid == $item->id)
            <option value="{{ $item->id }}" selected>
                {{ $item->configname }}
            </option>
        @else
            <option value="{{ $item->id }}">
                {{ $item->configname }}
            </option>
        @endif
    @else
        <option value="{{ $item->id }}">
            {{ $item->configname }}
        </option>
    @endif
    @if(!empty($item->children)) {{-- Or however you want to check for children --}}
        @if(isset($category))
            @include('admin.configuration.selectoption', ['configList' => $item['children'], 'category' => $category]){{-- Here I am just telling blade to treat the children as $items where they are passed through --}}
        @else
            @include('admin.configuration.selectoption', ['configList' => $item['children']]){{-- Here I am just telling blade to treat the children as $items where they are passed through --}}   
        @endif
    @endif
@endforeach

Above Code working perfectly but the option not indented. I want to generate the indent or space or hyphens before option based on level on recursion.

来源:https://stackoverflow.com/questions/32201890/how-to-indent-option-in-select-or-put-hyphens-before-each-sub-categories-option

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!