PHP Class macgyer\yii2materializecss\widgets\Dropdown

For example, php Please make sure that you provide the trigger with a data-activates attribute and specify the value of this attribute in the [[toggleTarget]] property of the widget.
See also: http://materializecss.com/navbar.html#navbar-dropdown
Author: Christoph Erdmann ([email protected])
Inheritance: extends macgyer\yii2materializecss\lib\BaseWidget
Show file Open project: macgyer/yii2-materializecss Class Usage Examples

Public Properties

Property Type Description
$encodeLabels whether the labels for header items should be HTML-encoded.
$items 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|array, optional, the url of the item link. This will be processed by yii\helpers\Url::to()-detail). If not set, the item will be treated as a menu header when the item has no sub-menu. - 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. - submenuOptions: array, optional, the HTML attributes for sub-menu container tag. If specified it will be merged with [[submenuOptions]]. To insert a divider use
  • .
    $submenuOptions the HTML attributes for sub-menu container tags. If not set - [[options]] value will be used for it.
    $toggleTarget the HTML id of the dropdown. This property specifies the target which shall be activated by the dropdown trigger. If you defined the following trigger Dropdown your [[toggleTarget]] has to be set to "dropdown1".

    Public Methods

    Method Description
    init ( ) Initializes the widget.
    run ( ) : string Renders the widget and registers the plugin asset.

    Protected Methods

    Method Description
    renderItems ( array $items, array $options = [] ) : string Renders menu items.

    Method Details

    init() public method

    If you override this method, make sure you call the parent implementation first.
    public init ( )

    renderItems() protected method

    Renders menu items.
    protected renderItems ( array $items, array $options = [] ) : string
    $items array the menu items to be rendered
    $options array the container HTML attributes
    return string the rendering result.

    run() public method

    Renders the widget and registers the plugin asset.
    public run ( ) : string
    return string the result of widget execution to be outputted.

    Property Details

    $encodeLabels public property

    whether the labels for header items should be HTML-encoded.
    public $encodeLabels

    $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|array, optional, the url of the item link. This will be processed by yii\helpers\Url::to()-detail). If not set, the item will be treated as a menu header when the item has no sub-menu. - 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. - submenuOptions: array, optional, the HTML attributes for sub-menu container tag. If specified it will be merged with [[submenuOptions]]. To insert a divider use
  • .
    public $items

    $submenuOptions public property

    the HTML attributes for sub-menu container tags. If not set - [[options]] value will be used for it.
    public $submenuOptions

    $toggleTarget public property

    the HTML id of the dropdown. This property specifies the target which shall be activated by the dropdown trigger. If you defined the following trigger Dropdown your [[toggleTarget]] has to be set to "dropdown1".
    public $toggleTarget