atayahmet / laravel-nestable

Laravel 5 nested category/menu generator
MIT License
214 stars 52 forks source link

Default first item #70

Open josegus opened 5 years ago

josegus commented 5 years ago

I need to render categories as dropdown, but need the first element to be empty. How can i set a default "Select one" with empty value and custom text?

mgazelle commented 5 years ago

Just add placeholder('','None') before calling the render function.

Example:

<?php

Category::attr(['name' => 'categories'])
    ->selected(2)
    ->placeholder('','None')
    ->renderAsDropdown();