Class hscstudio\heart\widgets\Dropdown

Inheritancehscstudio\heart\widgets\Dropdown » yii\bootstrap\Widget
Available since version2.0

Dropdown renders a Bootstrap dropdown menu component.

See also http://getbootstrap.com/javascript/#dropdowns.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$encodeLabels boolean Whether the labels for header items should be HTML-encoded. hscstudio\heart\widgets\Dropdown
$items array List of menu items in the dropdown. hscstudio\heart\widgets\Dropdown

Public Methods

Hide inherited methods

MethodDescriptionDefined By
init() Initializes the widget. hscstudio\heart\widgets\Dropdown
run() Renders the widget. hscstudio\heart\widgets\Dropdown

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
renderItems() Renders menu items. hscstudio\heart\widgets\Dropdown

Property Details

$encodeLabels public property

Whether the labels for header items should be HTML-encoded.

$items public property

List of menu items in the dropdown. Each array element can be either an HTML string, or an array representing a single menu with the following structure:

  • label: string, required, the label of the item link
  • url: string, optional, the url of the item link. Defaults to "#".
  • visible: boolean, optional, whether this menu item is visible. Defaults to true.
  • linkOptions: array, optional, the HTML attributes of the item link.
  • options: array, optional, the HTML attributes of the item.
  • items: array, optional, the submenu items. The structure is the same as this property. Note that Bootstrap doesn't support dropdown submenu. You have to add your own CSS styles to support it.

To insert divider use <li role="presentation" class="divider"></li>.

Method Details

init() public method

Initializes the widget.

If you override this method, make sure you call the parent implementation first.

void init( )
renderItems() protected method

Renders menu items.

string renderItems$items )
$items array

The menu items to be rendered

return string

The rendering result.

throws \yii\base\InvalidConfigException

if the label option is not specified in one of the items.

run() public method

Renders the widget.

void run( )