LoginSignup
5
5

More than 5 years have passed since last update.

Cakephp + Bootstrap で ドロップダウンボタン

Posted at

もう少しきれいになりそうではあるが

Helper

    public function dropDown($name, $links = array()) {
        return $this -> Html -> tag("div", join("", array(
            "",
            $this -> Form -> button("SELECT<span class='caret'></span>", array(
                "",
                "class" => "btn btn-default dropdown-toggle",
                "id" => $name,
                "data-toggle" => "dropdown"
            )),
            $this -> Html -> nestedList($links, array(
                "class" => "dropdown-menu",
                "role" => "menu",
                "aria-labelledby" => $name
            ), array("role" => "presentation"))
        )), array("class" => "dropdown"));
    }

View

<?php echo $this -> FormAssist -> dropDown("link1", array(
                $this -> Html -> link("Users", array(
                    "plugins" => "admins",
                    "controller" => "users",
                    "action" => "index"
                ), array(
                    "role" => "menuitem",
                    "tabindex" => -1
                )),
                $this -> Html -> link("Addresses", array(
                    "plugins" => "admins",
                    "controller" => "addresses",
                    "action" => "index"
                ), array(
                    "role" => "menuitem",
                    "tabindex" => -1
                )),
            ));
 ?>
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5