Contents
- Basic Concepts
- Introduction
- Processing user interactions
- Nesting leaves
- Data Binding
- Tutorial
- Building a blog
- View Bridges
- Introduction
- The model
- Re-rendering
- Events
- Handling Children
- Controls
- Extending View Bridges
- Control Components
- What is a control?
- Text Controls
- TextBox
- TextArea
- PasswordTextBox
- Selection Controls
- The selection control pattern
- Standard Variants
- DropDown
- CheckSet
- RadioButtons
- SearchControl
- ModelSearchControl
- Attaching additional data
- Dynamically driving the available items
- File Uploads
- SimpleFileUpload
- Html5FileUpload
- Other
- Buttons
- Building your own control
- Application Components
- What is an application component?
- Pager
- Table
- SearchPanel
- Tabs
- Advanced Topics
- View Indexes
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"];
}
}