Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setResult usage #33

Open
loranger opened this issue Jun 9, 2022 · 0 comments
Open

setResult usage #33

loranger opened this issue Jun 9, 2022 · 0 comments

Comments

@loranger
Copy link

loranger commented Jun 9, 2022

Hi,

I can't figure out how I can use the setResult method.

I miss an addCheckbox method so here is my workaround

$menu = $this->menu("Pick your items");

$selected = collect([]);

$list = collect(['Mozarella', 'Mushroom', 'Origan', 'Emmental']);
$list->each(function ($item) use ($menu, &$selected) {
    $menu->addCheckboxItem(ucfirst($item), function ($menu) use ($item, $selected) {
        $selected->push($item);
        $menu->setResult($selected);
    });
});

$items = $menu->open();

Unfortunately, this does not work because $menu is a CLIMenu instance instead of a Menu one:

Call to undefined method PhpSchool\CliMenu\CliMenu::setResult()

How are we supposed to use the Menu::setResult method ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant