Shiva
4 years ago
874
20
General

Getting a checkbox checked

Posted 4 years ago by Shiva

I've got a couple of checkboxes and I'm not sure how to go about getting it selected if the type is in the database

edit.blade.php

<div class="layout_type">
                <label>
                    <div class="checkbox">
                        <label>
                            <input type="checkbox" value="home" name="type"> Home
                        </label>
                    </div>
                </label>

                <label>
                    <div class="checkbox">
                        <label>
                            <input type="checkbox" value="about" name="type"> About
                        </label>
                    </div>
                </label>

                <label>
                    <div class="checkbox">
                        <label>
                            <input type="checkbox" value="contact" name="type"> Contact
                        </label>
                    </div>
                </label>
            </div>

MenusController

 public function edit($id)
    {
        $menus = Menu::find($id);
        $menu_id = Menu::lists('title', 'id');
        $selected_type = Menu::lists('title', 'id');
        if(is_null($menus)){
            return Redirect::route('admin.menus.edit');
        }

        return View::make('menus::edit', compact('menus', 'menu_id', 'selected_type'))->with($menu_id, $selected_type);
    }

Please sign in or create an account to participate in this conversation.