Skip to content

Feature request - ability to add sub-menu from addItem's callable #277

Open
@temuri416

Description

@temuri416

Something along these lines:

    $builder = (new CliMenuBuilder)
        ->addItem('Load Available Options', function (CliMenu $menuItem) {
            /**
             * Here I would load available options from DB and add them as $menu's subMenu
             */
            $loadedOptions = ['Opt1', 'Opt2', 'Opt3'];

            $builder = $menuItem->getBuilder();
            $subMenu = $builder->addSubMenu('Options');

            foreach ($loadedOptions as $opt) {
                $subMenu->addItem($opt);
            }

            $builder->build();
        })
        ->build();

    $builder->open();

In other words, a support for dynamically adding submenus when a menu item is selected would be an amazing feature.

Keep up the great work!

Thank you :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions