Contents

DropDown

DropDown is the most commonly used selection control by some margin. It presents a standard HTML select input with options driven from the selection items.

<?php

namespace Rhubarb\Leaf\Controls\Common\Examples\SelectionControls;

use Rhubarb\Leaf\Controls\Common\SelectionControls\DropDown\DropDown;
use Rhubarb\Leaf\Views\View;
use Rhubarb\Stem\Filters\StartsWith;

class ItemsByMixedView extends View
{
    protected function createSubLeaves()
    {
        $this->registerSubLeaf(
            $control = new DropDown("control")
        );

        $control->setSelectionItems(
            [
                [ "", "Please Select"],
                "Item 1",
                "Item 2",
                [ 3, "Item 3"],
                ExampleContact::all()->addSort("FirstName"),
                ExampleContact::all()->addSort("FirstName", false),
                (new ExampleContact())->getModelColumnSchemaForColumnReference("Status"),
                "Group 1" => [
                    ExampleContact::find(new StartsWith("FirstName", "J"))
                ]
            ]
        );
    }

    protected function printViewContent()
    {
        print $this->leaves["control"];
    }
}
                                    

Multi Select Drop Down

<?php

namespace Rhubarb\Leaf\Controls\Common\Examples\SelectionControls;

use Rhubarb\Leaf\Controls\Common\SelectionControls\MultiSelect\MultiSelectDropDown;
use Rhubarb\Leaf\Views\View;

class MultiSelectDropDownExampleView extends View
{
    protected function createSubLeaves()
    {
        $this->registerSubLeaf(
            $control = new MultiSelectDropDown("control")
        );

        $control->setSelectionItems(
            [
                "Item 1",
                "Item 2",
                "Item 3"
            ]
        );
    }

    protected function printViewContent()
    {
        print $this->leaves["control"];
    }
}